matlab常微分方程组求解
1个回答
展开全部
上面两题用dsolve都解不出,用ode45数值解法如下:
1题中x1=i,x2=s,则:
syms x1(t) x2(t)
lamda=0.5;u=0.1;
V = odeToVectorField(diff(x1) ==lamda*x1*x2-u*x2,diff(x2) ==-lamda*x1*x2+0.1)
M = matlabFunction(V,'vars', {'t','Y'})
%计算区间[0 1],初值[0 0]
options = odeset('OutputFcn',@odeplot);
sol = ode45(M,[0 1],[0 0],options)
2题中x=x1,y=x2,z=x3,则:
syms x1(t) x2(t) x3(t)
V = odeToVectorField(diff(x1) ==-8/3*x1+x2*x3,diff(x2) ==-10*x2+10*x3,diff(x3)==-x1*x2+28*x2-x3)
M = matlabFunction(V,'vars', {'t','Y'})
%计算区间[0 1],初值[0 0 1.0e-8]
options = odeset('OutputFcn',@odeplot);
sol = ode45(M,[0 4],[0 0 1.0e-8],options)
figure
x = linspace(0,4,100);
y = deval(sol,x,1:3);
plot(y(1,:),y(2,:))
title('x-y相图')
xlabel('x'),ylabel('y')
grid on
figure
plot(y(1,:),y(3,:))
title('x-z相图')
xlabel('x'),ylabel('z')
grid on
figure
plot3(y(1,:),y(2,:),y(3,:))
title('x-y-z相图')
xlabel('x'),ylabel('y'),zlabel('z')
grid on
1题中x1=i,x2=s,则:
syms x1(t) x2(t)
lamda=0.5;u=0.1;
V = odeToVectorField(diff(x1) ==lamda*x1*x2-u*x2,diff(x2) ==-lamda*x1*x2+0.1)
M = matlabFunction(V,'vars', {'t','Y'})
%计算区间[0 1],初值[0 0]
options = odeset('OutputFcn',@odeplot);
sol = ode45(M,[0 1],[0 0],options)
2题中x=x1,y=x2,z=x3,则:
syms x1(t) x2(t) x3(t)
V = odeToVectorField(diff(x1) ==-8/3*x1+x2*x3,diff(x2) ==-10*x2+10*x3,diff(x3)==-x1*x2+28*x2-x3)
M = matlabFunction(V,'vars', {'t','Y'})
%计算区间[0 1],初值[0 0 1.0e-8]
options = odeset('OutputFcn',@odeplot);
sol = ode45(M,[0 4],[0 0 1.0e-8],options)
figure
x = linspace(0,4,100);
y = deval(sol,x,1:3);
plot(y(1,:),y(2,:))
title('x-y相图')
xlabel('x'),ylabel('y')
grid on
figure
plot(y(1,:),y(3,:))
title('x-z相图')
xlabel('x'),ylabel('z')
grid on
figure
plot3(y(1,:),y(2,:),y(3,:))
title('x-y-z相图')
xlabel('x'),ylabel('y'),zlabel('z')
grid on
追问
直接把你的答案复制进去保存运行为什么没有出来图,什么也没有?这是怎么回事
追答
我这是有图的。不知你的软件是否有问题。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询