Borrar filtros
Borrar filtros

How to have variable-sized output for Simulink MATLAB-function block?

18 visualizaciones (últimos 30 días)
I have a MATLAB function-block in Simulink and I would like to have the output port of the block dynamically sized based on an input parameter. Eg:
function[y] = MATLABblock(u, s)
y = someCalc(u,s) %%Returns array of size s %%
Is this possible?

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 22 de Jul. de 2013
I think this should work as long as you can enforce a maximum size for y. Simulink currently does not support dynamic memory allocation, so you must specify a maximum-size for variable-size signals. Please see the section on Variable-Size Data in the documentation to ensure that your output is configured as variable-size.
  2 comentarios
Arun
Arun el 23 de Jul. de 2013
Hi! Thank you for your response. I have got it to work. However, is there a restriction on how many such ports in a block can be variable-sized? The reason is, I have 8 identical ports with identical Port Settings (variable size with an upper bound of 1024), but only one of them works.
Arun
Arun el 23 de Jul. de 2013
Sorry about the above comment. It was a bug in my code. I have corrected that and now it's all good. Thank you very much for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Model Verification en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by