Variable sizing must be enabled to generate code for ode45

Hi,
-------------the simulink model is attached-----------------------
I am a bit lost with the errors I get in my simulink model (I didn't use much simulink before). I have a Kalman Filter for which the transition function is given by a .m file
function x = myStateTransitionFcn(x,w)
%coder.varsize('s');
%y=zeros(1,2);
tf = 3;
t = linspace(0,tf,100);
s = zeros(100,6);
%x=[0,0,0,0,0,0];
[~,s] = ode45(@stateTransition,t, x);
x = s(100,1:6)';
% v = s(end,2);
end
which calls with ode45 a script defining the transition function
function ds = stateTransition(t,s) %(t, s, uTrans, uTransTime,uRot, uRotTime)
% actually there needs to be 2 u : one fore the translation uT and one for
% the rotation uR.
% hardcode some stuff
ds = zeros(6,1);
uTrans = ones(10,1)';
uTransTime = 0:9';
uRot = ones(10,1)';
uRotTime = 0:9';
uTrans = interp1(uTransTime, uTrans, t);
uRot = interp1(uRotTime, uRot, t);
ds(1) = s(4);
ds(2) = s(5);
ds(3) = s(6);
ds(4) = interp1q([0,2,3,5,6,7,8,9,10]', [0,0.2244,0.3850,0.6309,0.7839,1.022,1.1630,1.3959,1.5340]', uTrans) * cos(s(3));
ds(5) = interp1q([0,2,3,5,6,7,8,9,10]', [0,0.2244,0.3850,0.6309,0.7839,1.022,1.1630,1.3959,1.5340]', uTrans) * sin(s(3));
ds(6) = interp1((0:10:100)', [0, 6.3632, 16.8374, 25.6822, 35.5810, 45.7588, 53.0103, 60.5996, 83.5957, 89.0708, 96.1055]',uRot);
end
I get a lot of errors
----------------------------------------------
Source 'EKF/PN Sequence Generator' specifies that its sample time (-1) is back-inherited. You should explicitly specify the sample time of sources. You can disable this diagnostic by setting the 'Source block specifies -1 sample time' diagnostic to 'none' in the Sample Time group on the Diagnostics pane of the Configuration Parameters dialog box.
Component:Simulink | Category:Block warning
Variable sizing must be enabled to generate code for ode45.
Function 'myStateTransitionFcn.m' (#302.176.212), line 9, column 5:
"[r,s] = ode45(@stateTransition,t, x)"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'r'. The first assignment to a local variable determines its class.
Function 'myStateTransitionFcn.m' (#302.177.178), line 9, column 6:
"r"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 's'. The first assignment to a local variable determines its class.
Function 'myStateTransitionFcn.m' (#302.179.180), line 9, column 8:
"s"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 's'. The first assignment to a local variable determines its class.
Function 'myStateTransitionFcn.m' (#302.222.223), line 10, column 9:
"s"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed.
Function 'numericJacobian.m' (#303.2304.2316), line 69, column 5:
"func(vec{:})"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed.
Function 'EKFPredictorNonAdditive.m' (#304.2643.2719), line 68, column 24:
"matlabshared.tracking.internal.numericJacobian(f, {x, wZeros, params{:}}, 1)"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed.
Function 'Extras/EKFPredict_MLFcn_0Input/Predict' (#103.735.856), line 20, column 9:
"[xNew,PNew] = matlabshared.tracking.internal.EKFPredictorNonAdditive.predict(..."
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'xNew'. The first assignment to a local variable determines its class.
Function 'Extras/EKFPredict_MLFcn_0Input/Predict' (#103.736.740), line 20, column 10:
"xNew"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable 'PNew'. The first assignment to a local variable determines its class.
Function 'Extras/EKFPredict_MLFcn_0Input/Predict' (#103.741.745), line 20, column 15:
"PNew"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of MATLAB function 'Extras/EKFPredict_MLFcn_0Input/Predict'
Component:MATLAB Function | Category:Coder error
Library failed to build. Cannot continue build process.
Component:Stateflow | Category:Build error
Errors occurred during parsing of MATLAB function 'Extras/EKFPredict_MLFcn_0Input/Predict'
----------------------------------------------------------------------------------------
I don't understand how to solver the
Category:Block warning Variable sizing must be enabled to generate code for ode45.
Were in a .m file can I enable the variable size? I know I can do it under 'edit data' for a matlab function block but I don't know were to do this for a .m file.
Thanks for you help

1 Comment

Please attach your current .m files. (We can see from the error messages that the error messages you posted are for a different version of the source than you posted.)

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 9 Dec 2017

Commented:

on 9 Dec 2017

Community Treasure Hunt

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

Start Hunting!