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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Orion
Orion il 9 Dic 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 Commenti
Orion
Orion il 9 Dic 2014
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);
Bettina
Bettina il 10 Dic 2014
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!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Subsystems in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by