How to create array in Simulink with MATLAB function?
이전 댓글 표시
I have a Simulink model where I need to create an array based on two integers, say n and m. n and m are results from previous Simulink calculations and they change at each time step. If I would do this in MATLAB alone, I would do it in this way:
A = n:1:m
I tried to create a MATLAB function block with following code (which doesn't obviously work):
function A = fcn(n,m)
%#codegen
assert (n < 100);
assert (m < 100);
A = (n:1:m);
I get an following error message:
Computed maximum size of the output of function 'colon' is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [1 x :?].
I'm relatively new with MATLAB and Simulink and I just can't find a solution to my problem. Is there a suitable pre-made block for me or is there something I can do to improve my MATLAB function?
Once created, the array will be spit into While Iterator Subsystem, where each value will be individually modified based on few if-operators.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Test Model Components에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
