s-function error

2 vues (au cours des 30 derniers jours)
dragon kenn
dragon kenn le 29 Avr 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);

Réponses (1)

Les Beckham
Les Beckham le 29 Avr 2017
Replace mdlInitializes with mdlInitializeSizes

Catégories

En savoir plus sur Block and Blockset Authoring dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by