Dynamically defined matrices in Simulink

조회 수: 3 (최근 30일)
Daniel
Daniel 2013년 11월 5일
편집: Daniel 2013년 11월 5일
Hi,
I've got following problem. I want to declare a matrix which is created dynamically be adding rows in a loop. And i want to do that in Embedded Matlab Function in Simulink.
I tried it first in m-file like this:
function y = fcn(X)
X=[3 4; 4 5; 6 6; 3 4]
Y=[];
[l_x, l_y]=size(X);
for i=1:l_x
if i=2
Y=[Y ;X(i,:)];
else
Y=[Y ;X(i,:)];
end
end
y=Y;
end
So, in normal m-file it works properly, but in Simulink not. Anyone can think of a solution and what causes the problem?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 5일
What is the error message?
Daniel
Daniel 2013년 11월 5일
편집: Daniel 2013년 11월 5일
Its like this
Size mismatch (size [0 x 0] ~= size [1 x 2]
edit: made a mistake, now its correct (size is [1 x 2]) Function 'Embedded MATLAB Function' (#31.68.88), line 9, column 5:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by