Variable-size function in MATLAB FUNCTION Simulink Block

1 次查看(过去 30 天)
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 个评论
Ryan Livingston
Ryan Livingston 2013-7-30
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?

请先登录,再进行评论。

回答(1 个)

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

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by