필터 지우기
필터 지우기

Embeded MATLAB function variable-size signal

조회 수: 3 (최근 30일)
Daniel
Daniel 2014년 1월 10일
댓글: mettala 2016년 2월 22일
Hello all
I am simulating something on simulink that requires me to take some number as an input then
generate variable size output signal.
For example, say I have input that says 2, 14, 10.
I am supposed to create [1 by 2] vector then, [1 by 14] vector then, [1 by 10] and so on..
I know that my output variable will not exceed [1 by 10000], so I was trying to define inside function just to see if it works:
function y = fcn(u) %#codegen coder.varsize('y', [1 10000]); y = zeros(u, 1);
I also went to simulink->Edit Data then check my variable y to be variable size and I specified [1 10000], but
still it gives me an error saying:
Computed maximum size is not bounded. Static memory allocation requires all sizes to be bounded. The computed size is [:1 x ?].

채택된 답변

Ryan Livingston
Ryan Livingston 2014년 1월 16일
You can add calls to ASSERT which effectively bounds the values arguments:
function y = fcn(u)
%#codegen
N = 10000;
coder.varsize('y', [1 N]);
assert(u < N);
y = zeros(1, u);
should do the trick.
The error is effectively complaining about computing the size for the expression:
zeros(1, u);
Which, provided the information given it must assume is unbounded.
You can reference:
for more documentation on this approach.
  댓글 수: 1
mettala
mettala 2016년 2월 22일
I have somewhat similar problem as Daniel had 2 years ago. I tried to use your function with constant input of 14 (or any other value) and get the following error message:
The signal at output port 2 of 'XXX' is a variable-size signal with a nondiscrete sample time.
The sample time for any variable-size signal must be discrete.
I have changed the output to variable and size is specified [1 10000].

댓글을 달려면 로그인하십시오.

추가 답변 (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