フィルターのクリア

Dimension varies error message on real time aplication

1 回表示 (過去 30 日間)
Haritz Odriozola Olalde
Haritz Odriozola Olalde 2021 年 7 月 12 日
コメント済み: dpb 2021 年 7 月 12 日
Hi everyone,
I'm trying to run my code, which is defined on a Matlab Function on Simulink, on a real time target PC.
This is my code:
%--------------------------------------------------------------------------
% Inicialización de variables
%--------------------------------------------------------------------------
if k > H+1
yp = yk(k-H:k-1,1);
else
yp = zeros(H,1);
end
up = xf;
% Si Hc es menor que H
for i=(Hc+1):H
up(:,i)=up(:,Hc);
end
H has a constant value of 4
K is a value that can vary from 1 to 400 on each iteration.
I have predefined yp as a 4x1 vector, and as you can see in the code that I attach, yp is always going to be a 4x1 dimension vector. However, the error message that pops out after running the scripts (that you can also see in the following screenshot) says that the dimension of yk varies.
I don`t understand what is happening and why it says that its dimension varies if I have defined it clearly that it is a 4x1 vector.
Thanks a lot.
  1 件のコメント
dpb
dpb 2021 年 7 月 12 日
yp = yk(k-H:k-1,1);
The subscript expression k-H:k-1 certainly is NOT a constant expression even though it computes to four elements in length. It appears the parser can only check and accept invariant expressions in whatever context it is that the code is being used in Simulink (which I don't have so can't test anything).
What happens if you assign the RHS to a temporary variable instead and then assign it to yp? The runtine should then see the result matches...
ytmp = yk(k-H:k-1,1);
yp=ytmp;

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeConfigure and View Diagnostics についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by