Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab中的ODE45误差_Matlab - Fatal编程技术网

Matlab中的ODE45误差

Matlab中的ODE45误差,matlab,Matlab,请注意,我的程序一直在生成错误代码,我尝试了各种方法来调试它,但都没有用。请帮忙。以下是代码和错误 function xdot= Inverter(k,x) xdot=zeros(4,1); w= 376.991; Lf= 800e-6; Cf=75e-6; t=0:1; vd=4*sin(w*t); vq=4*sin(w*t+ pi/2); ild = 9.5*sin(w*t); ilq= 9.5*sin(w*t+ pi/2); % initial conditions xdot(1

请注意,我的程序一直在生成错误代码,我尝试了各种方法来调试它,但都没有用。请帮忙。以下是代码和错误

function xdot= Inverter(k,x)

 xdot=zeros(4,1);

w= 376.991;
Lf= 800e-6;
Cf=75e-6;
t=0:1;
vd=4*sin(w*t);
vq=4*sin(w*t+ pi/2);

ild = 9.5*sin(w*t);
ilq= 9.5*sin(w*t+ pi/2);
% initial conditions

xdot(1) = vd/Lf + w*x(2)- x(3)/Lf;
xdot(2) = vq/Lf - w*x(1) + x(4)/Lf;
xdot(3) = x(1)/Cf + w*x(4)- ild/Cf;
xdot(4) = x(2)/Cf - w*x(3)- ilq/Cf;

xdot = [xdot(1); xdot(2); xdot(3); xdot(4)];

[k,x]=ode45(@Inverter,[0 0.5 ], [0 0 0 0]');
figure(1) ,plot(k,x(:,3))



Error is:

???  In an assignment  A(I) = B, the number of elements in B and
 I must be the same.

Error in ==> Inverter at 16
xdot(1) = vd/Lf + w*x(2)- x(3)/Lf;

Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in ==> inv2 at 1
[k,x]=ode45(@Inverter,[0 0.5 ], [0 0 0 0]');

这些是我每次运行程序时不断得到的错误代码。谁来帮忙!谢谢

我猜
k
是你的时间
t
,所以你真的需要:

vd=4*sin(w*k);
vq=4*sin(w*k+ pi/2);

ild = 9.5*sin(w*k);
ilq= 9.5*sin(w*k+ pi/2);

您可以去掉
t=0:1的行。行
xdot=[xdot(1);xdot(2);xdot(3);xdot(4)]也是多余的。

旁注:这一行似乎已过时:
xdot=[xdot(1);xdot(2);xdot(3);xdot(4)]程序现在运行正常。Thanks@AyindeBabajide如果答案能帮助你解决问题,你能接受吗?