s-function error

2 ビュー (過去 30 日間)
dragon kenn
dragon kenn 2017 年 4 月 29 日
回答済み: Les Beckham 2017 年 4 月 29 日
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);

回答 (1 件)

Les Beckham
Les Beckham 2017 年 4 月 29 日
Replace mdlInitializes with mdlInitializeSizes

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by