Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulink - Embedded Matlab Function - Size of function not bounded error

217 views
Skip to first unread message

Elliot

unread,
Jul 18, 2011, 2:22:15 PM7/18/11
to
Hey all,
I'm trying to convert a .m file into something usable by a user defined function block in simulink but am having trouble with the following style of equation:

x = exp([-y:y]);
where y is an integer which normally has a value between 40 and 120.

Running this through simulink results in the following error:
------------------------------------------------
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 :?].

Function 'testing.m' line 8, column 14:
"[-y:y]"
----------------------------------------------------

I know simulink doesn't like variably sized arrays/matrices but I'm not sure I can set an upper bound in this case since it's referring to the operation itself rather than x or y.
Anyone know of a potential work around for this?

Cheers.

Phil Goddard

unread,
Jul 18, 2011, 3:13:08 PM7/18/11
to
What sort of user defined function: Embedded MATLAB, S-Fuction, MATLAB Fcn Block?

Is y and input?
Is x an output?
Or are they local variables?

Phil.

Elliot

unread,
Jul 18, 2011, 5:39:09 PM7/18/11
to
"Phil Goddard" <ph...@modeling-simulation-visualization.com> wrote in message <j020k4$gkv$1...@newscl01ah.mathworks.com>...


Sorry should have been more clear. It is an Embedded Matlab Function block, x and y are just local variables in this case, though there is a similar function towards the end of the code where the "x" is an output (haven't quite made it that far though).

Thanks,
-Elliot

Phil Goddard

unread,
Jul 18, 2011, 5:46:09 PM7/18/11
to

You need to use something like an "assert" function prior to the colon operator so that the EML block knows an upper bound on your y variable.

A example, where y is the output in this case, would be

%%%%%%%%%%% Cut here %%%%%%%%%%
function y = fcn(u)
%#eml
assert(u<100);
vTemp = -u:u;
y = exp(vTemp)';
%%%%%%%%%%% Cut here %%%%%%%%%%

Search the doc for the text "Specifying Upper Bounds for Local Variable-Size Data" to see where this is documented.

Phil.

Elliot

unread,
Jul 19, 2011, 5:42:12 AM7/19/11
to
"Phil Goddard" <ph...@modeling-simulation-visualization.com> wrote in message <j029j1$dq9$1...@newscl01ah.mathworks.com>...

Works just fine now, cheers!

-Elliot

0 new messages