필터 지우기
필터 지우기

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 CenterFile Exchange에서 Configure 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