Simscape tablelookup input value

10 Ansichten (letzte 30 Tage)
Mahmoud Seboui
Mahmoud Seboui am 4 Sep. 2019
Beantwortet: Shubham Kashyap am 10 Jun. 2020
I'm trying to create a custom simscape component and I'm facing problem using "tablelookup".
the component has n spatial section. A physical parameter "y" of each section should be determined using "tablelookup" based on user defined values in the parameter section.
a very simplified code to reproduce the case is as follow:
component Vect
outputs
f = 0;
end
parameters
u1 = [1 1 ];
u2 = [1 1.5 ];
end
parameters(Access=private)
x1d = [1 2 3 4];
x2d = [1 2 3];
y = [1 2 3; 3 4 5; 5 6 7; 7 8 9];
end
equations
f == tablelookup(x1d, x2d, y, u1, u2, interpolation = linear, extrapolation = nearest);
end
end
I'm getting the following error while compiling:
Error compiling Simscape network for model sim_Vect.
Caused by:
['sim_Vect/Simscape Component']: Function, tablelookup, is wrong. Please check 1)
whether input data points have correct sizes; 2) query values are scalar; 3)
query values and table data have the commensurate units; and 4) constants or
compile time parameters are passed to interpolation and extrapolation argument. In Vect (line 19)
Argument 1 = [1 2 3 4]
Argument 2 = [1 2 3]
Argument 3 = [4x3 double]
Argument 4 = [1 1]
Argument 5 = [1 1.5000]
x1d = [1 2 3 4]
x2d = [1 2 3]
y = [4x3 double]
u1 = [1 1]
u2 = [1 1.5000]
Component:Simulink | Category:Model error
My problem is that it seems to me like tablelookup can only work with single input value.
The point is that the number of sections n is probably unknown and even if's known it could be very big(100 to 1000 entry) so I can't call tablelookup for every single section separatly.
As I'm not very experienced with simscape, I might be missing something or misunderstanding the tablelook up function.
So could you please help me to realise this functionality or share a workarround?

Antworten (2)

J Chen
J Chen am 6 Sep. 2019
Several options: 1) use the Simscape built-in PS Lookup Table (2D) block instead of a custom block. 2) study the example here. 3) build the component with Simulink blocks and use PS-Simulink converters to interface with your Simscape model.
  2 Kommentare
Mahmoud Seboui
Mahmoud Seboui am 9 Sep. 2019
Hi J Chen,
Thank you for your response!
Actually this is not the whole code but part of it, so my final goal is not creating a lookup table but to use it within my component.
I already have the simulink model (of the component) and I use it in the way you mention in (3) but I wanted to create the component in simscape with the hope to increase the performace of the whole model.
J Chen
J Chen am 11 Sep. 2019
I think the problem might be that the u1 and u2 in the following command need to be scaler. They can't be vectors as in your code.
f == tablelookup(x1d, x2d, y, u1, u2, interpolation = linear, extrapolation = nearest);
The error message (2) seems to support my assumption.

Melden Sie sich an, um zu kommentieren.


Shubham Kashyap
Shubham Kashyap am 10 Jun. 2020
In the ‘tablelookup’ documentation, it specifies:
“For two-dimensional table lookup, yd must be a matrix, with the size matching the dimensions defined by the input data sets. For example, if x1d is a 1-by-m array, and x2d is a 1-by-n array, then yd must be an m-by-n matrix.”
tablelookup(x1d, x2d, yd, x1, x2, interpolation = linear|cubic|spline, extrapolation = linear|nearest)
This means that m x n matrix is referenced by:
A) First input lookup data (x1d) references rows (m) of a lookup table.
B) and the second input lookup data (x2d) references the column (n) of a lookup table.
For example, the proper input order using 'tablelookup' function is shown below:
density_out = tablelookup(B.temperature, B.pressure, B.density, T_out, P_out, interpolation = spline, extrapolation = nearest);
For the code above, since m x n is ‘pressure’ x ‘temperature’:
A) x1d – should have input lookup data of pressure data
B) x2d – should have input lookup data of temperature data.
Corrective Methods:
A) Enter the input lookup data set as per order mentioned above.
B) OR transpose the lookup table.
Please refer to following documentation on ‘tablelookup’ for more information on interpolation method:

Kategorien

Mehr zu Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by