s-function error

2 visualizaciones (últimos 30 días)
dragon kenn
dragon kenn el 29 de Abr. de 2017
Respondida: Les Beckham el 29 de Abr. de 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);

Respuestas (1)

Les Beckham
Les Beckham el 29 de Abr. de 2017
Replace mdlInitializes with mdlInitializeSizes

Categorías

Más información sobre Block and Blockset Authoring en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by