MATLAB中螺旋桨的仿真建模
在MATLAB中建立螺旋桨的模型,作为电机的负载。调用S函数出现问题,Output returned by S-function 'chazhi' in 'propeller/Subsystem/S-Function' during flag=3 call must be a real vector of length 2S函数如下:
%插值运算
%输入量:u(1)=J;u(2)=Kt,u(3)=Kp;u(4)=J0;
%输出量:Kt0,Kp0
function = chazhi(t,x,u,flag)
switch flag
case 0
=mdlInitializeSizes;
case 1
sys=mdlDerivatives(t,x,u);
case 3
sys=mdlOutputs(t,x,u);
case {2,4,9}
sys=[];
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
%------------------------------------------------------
%初始化子函数
function=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=0;
sizes.NumDiscStates=0;
sizes.NumOutputs=2;
sizes.NumInputs=28;
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=1;
sys=simsizes(sizes);
x0=[];
str=[];
ts=;
%------------------------------------------------------
%状态变量导数子函数
function sys=mdlDerivatives(t,x,u)
%------------------------------------------------------
%输出子函数
function sys=mdlOutputs(t,x,u)
J=;
Kp=;
Kt=;
J0=u(28);
J1=J0';
Kpj=interp1(J,Kp,J1,'cubic');
Ktj=interp1(J,Kt,J1,'cubic');
sys(1)=Kpj;
sys(2)=Ktj; 刚刚把simulink仿真图放上来了,怎么不显示呀 有没有做船用螺旋桨仿真的同学,大家讨论看看。
页:
[1]