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

18 次查看(过去 30 天)
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?

采纳的回答

Kaustubha Govind
Kaustubha Govind 2013-7-22
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 个评论
Arun
Arun 2013-7-23
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 2013-7-23
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Model Verification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by