Variable-size function in MATLAB FUNCTION Simulink Block

1 view (last 30 days)
I'm working with the Simulink block MATLAB FUNCTION and I'm having problems with the bounds of the variables that I define in there.
This is the part of the code where I’m getting troubles
function P_S1_100= fcn(SOC_S1_100,S1_AGENTS_10,time_CAP_100)
assert(time_CAP_100(1)<100)
tcharging_a1_1=[0:0.05:time_CAP_100(1)]
tcharging_a1_2=[time_CAP_100(1):0.05:time_CAP_100(1)*2]
tcharging_a1=[0:0.05:time_CAP_100(1)
(Where time_CAP_100 is a vector [1x6])
And this is the error that I'm getting:
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 'Subsystem1/Slow Charge/S1/MATLAB Function5' (#265.262.302), line 8, column 16:
"[time_CAP_100(1):0.05:time_CAP_100(1)*2]"
I've tried with
coder.varsize('tcharging_a2_2',[1 200])
And I have also bounded the input/output variables with the Edit Data box of the MATLAB FUNCTION block Editor. But, I still get the same error.
Since the other two variables (tcharging_a1 and t_charging_a1_1) are not giving troubles (even when both depend on the first value of 'time_CAP_100'); I guess that the problem might be caused by the depence of the uper and lower bound of 'tcharging_a1_1'on the value of 'time_CAP_100 (1)'
Could anyone give me an idea of how to solve this error?
Thanks in advance.
  1 Comment
Ryan Livingston
Ryan Livingston on 30 Jul 2013
If you try to put the upper bound in a variable:
ub = time_CAP_100(1)*2;
tcharging_a1_2 = time_CAP_100(1):0.05:ub;
does that help anything?

Sign in to comment.

Answers (1)

salah sh
salah sh on 20 Oct 2014
hi . did you solve this problem ?? i have also the same problem und i really need the soluation

Community Treasure Hunt

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

Start Hunting!