필터 지우기
필터 지우기

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