フィルターのクリア

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

1 回表示 (過去 30 日間)
Bettina
Bettina 2014 年 12 月 9 日
コメント済み: Bettina 2014 年 12 月 10 日
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!

採用された回答

Orion
Orion 2014 年 12 月 9 日
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 件のコメント
Orion
Orion 2014 年 12 月 9 日
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 2014 年 12 月 10 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by