马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
xt.m
(1.24 KB, 下载次数: 8)
我在运行Simulink仿真的时候,出现以下提示,Output returned by S-function 'xt' in 'fuzzy_slide/S-Function1' during flag=3 call must be a real vector of length 2。
怎么改都不行,不知道怎么办了。
程序如下:
%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;
case 1,
sys=mdlDerivatives(t,x,u);
%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 = 3;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 2;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 0;
sys=simsizes(sizes);
x0=[0,0,0];
str=[];
ts=[];
function sys=mdlDerivatives(t,x,u)
% x=u(1);
% sys(1)=2.1809*wt+0.036*x1+0.00002*Qs+0.1*u(1); % dwt
% sys(2)=1800/35*wt-1800/35*x1+1/35*Qs-1/35*u(2); % dwg
% sys(3)=(100+5.4)*wt-100*x1; % dQs
sys(1)=2.1809*u(3)+0.036*x1+0.00002*Qs+0.1*u(1); % dwt
sys(2)=1800/35*u(3)-1800/35*x1+1/35*Qs-1/35*u(2); % dwg
sys(3)=(100+5.4)*u(3)-100*x1; % dQs
function sys=mdlOutputs(t,x,u)
% dQs=(100+5.4)*wt-100*x1;
dQs=(100+5.4)*u(3)-100*x(1);
%x3=u(1);
sys(1)=x(1);
%sys(2)=u(1);
%sys(3)=dQs;
sys(2)=dQs;
fuzzy_slide.mdl
(49.05 KB, 下载次数: 19)
s.m
(1.1 KB, 下载次数: 17)
rule.m
(1.8 KB, 下载次数: 16)
|