登录论坛

查看完整版本 : [求助]想做X(1)与dx(1)/dt的平面图


fp123456
2009-03-02, 23:19
求助:

想做X(1)与dx(1)/dt的平面图。

程序中,X(6)=dx(1)/dt ,采用了微分代数方程求解的方法。

但做不出来,从输出的图形来看X(1)和X(6)基本上是同相位,没有看到微分的效果。

不知道程序有啥错误。

请指教!

谢谢!



定义函数程序

function xdot = fun(t,x)
r1=0.0003;r2=0.0003;r3=0.0003;g=1e-9;a1=41.3*1e-6;a2=41.3*1e-6;a3=41.3*1e-6;b1=0.246*1e-6;b2=0.246*1e-6;b3=0.246*1e-6;c1=0;c2=0;c3=0;C=0.3334;Em=8100;
xdot=[-r1*(a1*x(1)+b1*x(1)^3+c1*x(1)^5)+x(4)+Em*sin(314*x(5));-r2*(a2*x(2)+b2*x(2)^3+c2*x(2)^5)+x(4)+Em*sin(314*x(5)-2.1);-r3*(a3*x(3)+b3*x(3)^3+c3*x(3)^5)+x(4)+Em*sin(314*x(5)+2.1);-(a1*x(1)+b1*x(1)^3+c1*x(1)^5+a2*x(2)+b2*x(2)^3+c2*x(2)^5+a3*x(3)+b3*x(3)^3+c3*x(3)^5)/(3*C)-g*x(4)/C;1;-r1*(a1*x(1)+b1*x(1)^3+c1*x(1)^5)+x(4)+Em*sin(314*x(5))-x(6)];




运行程序程序名K1



clear,clc,clf;
M=[1,0,0,0,0,0;0,1,0,0,0,0;0,0,1,0,0,0;0,0,0,1,0,0;0,0,0,0,1,0;0,0,0,0,0,0];
options=odeset;option.Mass=M;
tfinal=0.3;x0=[2,-0.2,-1,0,0,0];
[t,x]=ode45('fun',[0,tfinal],x0);
figure(1)
hold on
plot(t,x(:,1),'-r')
xlabel('t')
ylabel('va')
figure(2)
plot(t,x(:,2),'-.b')
xlabel('t')
ylabel('vb')
figure(3)
plot(t,x(:,3),'k')
xlabel('t')
ylabel('vc')
figure(4)
%plot3(x(:,1),x(:,2),x(:,3))
%plot(x(:,5),x(:,1))
plot(x(:,1),x(:,6))