Search code examples
functionimportinterpolationmodelica

Function not found in the scope of a model


My simple Modelica code is as follows and received the error: Function Vectors.interpolate not found in scope interpo.

model interpo
  import Modelica.SIunits.{Temperature, Length};
  import Modelica.Math.Vectors.interpolate;
  parameter Temperature thetas[5] = {45, 46, 54, 48, 51};
  parameter Length barycenters[5] ={2, 4, 6, 8, 10};
  parameter Length x_sens[3] = {3,5,7};
  Temperature thetas_sens[3];
 
equation
thetas_sens = Vectors.interpolate(barycenters, thetas, x_sens);

end interpo;

I would appreciate if you could help.


Solution

  • The equation should be thetas_sens = interpolate(barycenters, thetas, x_sens) since you already imported the package Vectors. This will remove the error and reveal that you cannot call interpolate with a vector of independent variables. So you must loop through the vector.