请教:运行S函数出错One or more output arguments not assigned during call to
我的S函数是:%S-function for continuous state equation
function =s_function(t,x,u,flag)
switch flag,
%Initialization
case 0,
=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 =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 编辑 ]
回复 楼主 ezekyal 的帖子
看看此帖:http://forum.vibunion.com/forum/thread-29615-1-1.html
http://topic.csdn.net/u/20080509/11/3e90b090-d121-4359-a151-be29c0253d81.html u==0没有 把整个程序看一下 也要包含所有情况 另外没必要用s函数 原帖由 yufeng 于 2008-12-13 07:49 发表 http://www.chinavib.com/forum/images/common/back.gif
u==0没有 把整个程序看一下 也要包含所有情况 另外没必要用s函数
那用什么啊,我是新手,好多东西还不太会呢
页:
[1]