查看: 784|回复: 0|关注: 0

[未答复] simulink中s函数的参数未定义问题

[复制链接]

新手

5 麦片

财富积分


050


4

主题

4

帖子

0

最佳答案
发表于 2019-1-11 20:29:22 | 显示全部楼层 |阅读模式
用s函数搭建了一个永磁同步电机,到了最后出现了参数未定义的问题。如图,框里面的参数是什么,有大神给填一下么。s函数编程如下
function[ sys, x0, str, ts]=PMSMdq(t,x,u,flag,parameters,x0_in)
%PMSM model.
%parameters;
%ld,lq:inductance in dp reference of frame
%r:stater resistance
%psi_f:flux in webers by PM on rotor
%p:number of pole pairs
%j:inertia of motor and load
%mu_f:viscous friction
%inputs:
%ud,uq:voltages in dp reference of frame
%tl:torque of load
%inner variants:
%id,iq currents in dp reference of frame
%ud,uq:voltage int dp reference of frame
%wr:angular velocity of the rotor
%te:electronmagnetic torque
%theta: position of rotor
%outputs:
%wr:angular velocity of the rotor
%te:electronmagnetic torque
%id,iq currents in dp reference of frame
%theta :position of rotor
%----------------------------
%u(1 2 3)=
%ud uq tl
%parameters (1 2 3 4   5 6 7)=
%           ld lq r psi_f p j mu_f
%sys(1 2 3 4 5 )=
%    wr te id iq theta
%x(1 2 3 4 )=
%   id iq wr theta
switch flag
    case 0
        [sys x0 str ts]=mdlInitializeSizes(x0_in);%iniatialization
    case 1
        %calculate the derivatives
        sys=mdlDerivatives(x,u,parameters);
    case 3
        %output
        sys=mdlOutputs(x,u,parameters);
    case{2,4,9}
        %unused flags
        sys=[];
    otherwise
        %Error handling
        error(['Unhandled flag=',num2str(flag)]);
end
%end of PMSMdq
%-----------------------------------
%mdlInitializeSizes
%----------------------------------
function[sys,x0,str,ts]=mdlInitializeSizes(x0_in)
%-------------------------------------
%u(1 2 3)=
%   ud uq tl
%parameters(1 2 3 4 5 6 7 )=
%           ld lq r psi_f p j mu_f
%x( 1 2 3 4)=
%  id iq wr theta
sizes=simsizes;
sizes.NumContStates=4;
sizes.NumDiscStates=0;
sizes.NumOutputs=5;
sizes.NumInputs=3;
sizes.DirFeedthrough=0;
sizes.NumSampleTimes=1;
sys=simsizes(sizes);
x0=x0_in;
str=[];
ts=[0 0];
%End of mdlInitializeSizes.
%---------------------------
%mdlDerivatives
%Return the derivatives for the continuous states
%-----------------------------
function[ sys ]=mdlDerivatives(x,u,parameters)
%-----------------------------
%u( 1 2 3)=
%   ud uq tl
%parameters(1 2 3 4 5 6 7)=
%            ld lq r psi_f p j mu_f
%sys(1 2 3 4 5)=
%    wr te id iq theta
%x(1 2 3 4)=
%   id iq wr theta
%id'=ud/ld-r*iq/lq+lq*p*wr*iq/ld
sys(1)=u(1)/parameters(1)-parameters(3)*x(1)/parameters(1)+parameters(2)*parameters(5)*x(3)*x(2)/parameters(1);
%iq'=uq/lq-r*iq/lq-ld*p*wr*id/lq-psi_f*p*wr/lq
sys(2)=u(2)/parameters(2)-parameters(3)*x(2)/parameters(2)-parameters(1)*parameters(5)*x(3)*x(1)/parameters(2)-parameters(4)*parameters(5)*x(3)/parameters(2);
%te=1.5*p*[psi_f*iq+(ld-lq)*id*iq]
te=1.5*parameters(5)*(parameters(4)*x(2)+(parameters(1)-parameters(2))*x(1)*x(2));
%wr'=(te-mu_f*wr-tl)/j
sys(3)=(te-parameters(7)*x(3)-u(3))/parameters(6);
%theta'=p*wr
sys(4)=parameters(5)*x(3);
%End of mdlDerivatives
%-------------------------------------------
%mdlOutputs
%Return the block outputs.
%-----------------------------------------
function sys=mdlOutputs(x,u,parameters,te)
%------------------------------------------
%u(1 2 3)=
%   ud uq tl
%parameters(1 2 3 4 5 6 7)=
%          ld lq r psi_f p j mu_f
%sys(1 2 3 4 5)=
%    wr te id iq theta
%x(1 2 3 4 )=
%    id iq wr theta
%output wr
sys(1)=x(3);
%output te
%te=1.5*p*[psi_f*iq+(ld-lq)*id*iq]
te=1.5*parameters(5)*(parameters(4)*x(2)+(parameters(1)-parameters(2))*x(1)*x(2));
sys(2)=te;
%output idq
sys(3)=x(1);%id
sys(4)=x(2);%iq
%out theta
sys(5)=x(4);
%End of mdlOutputs

QQ截图20190111202836.png
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐上一条 /3 下一条

快速回复 返回顶部 返回列表