SIMULINK Action subsystem with 1D-lookup Table, which data is not always available

Hello everybody,
I have question regarding Simulink subsystems, look-up tables and size mismachtes:
In my model I have two subsystems, which are controlled via a if-block. So subsystem number one is activated, if I have one type of aggregat, subsystem two, if I have another aggregat. Inside each subsystems I use the interp1 command in a MatLab Function block.
My problem is, that if on type of aggreagt activates one subsystem, the input data for interp1 look-up-table in the second subsystem is X=0,Y=0. So I get the error message: "There should be at least two data points."
But if I try this:
if size(X,1)==1
X=[X X+1];
Y=[Y Y];
end
Data=interp1(X,Y,xi);
I get the error message "size mismatch (size[1x1]~=size[1x2]).
Anybody a idea or tipss how to solve this? Thanks!

 Akzeptierte Antwort

Orion
Orion am 9 Dez. 2014
Hi,
First, why don't you use a look-up table block instead of a matlab function ?
Second, are you sure of the values of X and Y when the error occured ? You can profit the use of a matlab function by putting a breakpoint at the line Data=interp1(X,Y,xi);. This way the simulation will pause every time you arrive there, and you can check the values of all your variables inside the command window.

3 Kommentare

Bettina
Bettina am 9 Dez. 2014
Bearbeitet: Bettina am 9 Dez. 2014
Hey Orion,
1) I have a big calculation with the values before and after the use of the Look-up table, so it is not possible as simulink block.
2) Yes I am sure: I load a dataset for different aggregat types, so I know the values and I did use the debugging mode with the breakpoints. I had a similar problem with the simulink look-up block, where I did the above mentioned solution, BEFORE putting the data in the simulink look-up block. But as I have to use it inside the matlab function block, I have to change the X=0 and Y=0 for the interp1 command to something with two data points.
I wasn't paying attention.
The error occured because you redefined the inputs X and Y. It works In Matlab, but this is not working in Simulink, because Simulink need to calculate the size of the I/O signals, and here, it can't be done.
One way to solve your issue :
if size(X,1)==1
Abs = [X X+1];
Ord = [Y Y];
else
Abs = X;
Ord = Y;
end
Data=interp1(Abs,Ord,xi);
Hey Orion,
thanks for this - that was exactly my problem, but I didn't get the easy idea to define a new variable ... works fine - thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 9 Dez. 2014

Kommentiert:

am 10 Dez. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by