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!
