How to create array in Simulink with MATLAB function?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Test Model Components en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
