马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我的S函数是:
%S-function for continuous state equation
function [sys,x0,str,ts]=s_function(t,x,u,flag)
switch flag,
%Initialization
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
%Outputs
case 3,
sys=mdlOutputs(t,x,u);
%Unhandled flags
case {2, 4, 9 }
sys = [];
%Unexpected flags
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
%mdlInitializeSizes
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;
sys=simsizes(sizes);
x0=[];
str=[];
ts=[];
function sys=mdlOutputs(t,x,u) %u(1) u(2)分别表示定子磁链在两相坐标系下的两个分量
if(u(1)>0)
if(u(2)<0.5*u(3)&&u(2)>-0.5*u(3))
sys=1; %定子磁链落在区域1
end
if(u(2)<u(3)&&u(2)>0.5*u(3))
sys=2; %定子磁链落在区域2
end
if(u(2)<-0.5*u(3)&&u(2)>-u(3))
sys=6; %定子磁链落在区域6
end
end
if(u(1)<0)
if(u(2)<0.5*u(3)&&u(2)>-0.5*u(3))
sys=4; %定子磁链落在区域3
end
if(u(2)<u(3)&&u(2)>0.5*u(3))
sys=3; %定子磁链落在区域4
end
if(u(2)<-0.5*u(3)&&u(2)>-u(3))
sys=5; %定子磁链落在区域5
end
end
出现错误提示:Error in 'untitled/Subsystem2/S-Function' while executing M-File S-function 'clarea', flag = 3 (output), at time 0. MATLAB error message:
One or more output arguments not assigned during call to 'E:\MATLAB701\work\work5\clarea.m (mdlOutputs)'
请教各位高手们,如何修改才行。非常感谢。
[ 本帖最后由 ezekyal 于 2008-12-12 16:49 编辑 ] |