s-function error

2 views (last 30 days)
dragon kenn
dragon kenn on 29 Apr 2017
Answered: Les Beckham on 29 Apr 2017
Hello i have a problem with my s-function
i have this error after run my simulink
'smtest/S-function'while executing M-File S-function 's-function',flag=0(initialize),at start of simulation.MATLAB error message:Undefined function or variable 'mdllnitializes' this is the function
function [sys,x0,str,ts]=s_function(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializes;
case 1,
sys=mdlDerivatives(t,x,u);
case {2,4,9}
sys=[];
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=2;
sizes.NumDiscStates=0;
sizes.NumOutputs=2;
sizes.NumInputs=1;
sizes.DirFeedthrough=0;
sizes.NumSampleTimes=0;
sys=simsizes(sizes);
x0=[0.5 1.0];
str=[];
ts=[];
function sys=mdlDerivatives(x,u)
J=10;
sys(1)=x(2);
sys(2)=1/J*u;
function sys=mdlOutputs(x,u,t)
sys(1)=x(1);
sys(1)=x(2);

Answers (1)

Les Beckham
Les Beckham on 29 Apr 2017
Replace mdlInitializes with mdlInitializeSizes

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!