I want to draw dual phase portraits in a 4x4 linear differential equation system. My codes contain 4 variables as below (x1, x2, y1, y2). For a given coefficients matrix, when
2 次查看(过去 30 天)
显示 更早的评论
p=0.1; q=15;
x1dom = linspace(-p,p,q);x2dom = linspace(-p,p,q);y1dom = linspace(-p,p,q);y2dom = linspace(-p,p,q);
[X1,X2,Y1,Y2] = ndgrid(x1dom,x2dom,y1dom,y2dom);
A=[1.1 0 0.8 0 ; 0 1.2 0 0 ; 0 0 -0.9 0 ; 0 0 0 -0.5];
X1dot= A(1,1)*X1 + A(1,2)*X2 + A(1,3)*Y1 + A(1,4)*Y2;
X2dot= A(2,1)*X1 + A(2,2)*X2 + A(2,3)*Y1 + A(2,4)*Y2;
Y1dot= A(3,1)*X1 + A(3,2)*X2 + A(3,3)*Y1 + A(3,4)*Y2;
Y2dot= A(4,1)*X1 + A(4,2)*X2 + A(4,3)*Y1 + A(4,4)*Y2;
quiver(X1,X2,X1dot,X2dot)
0 个评论
采纳的回答
Wan Ji
2021-8-26
Looks like an ode function, so use matlab ode solver to solve it. Here I give an example of ode 45.
A = rand(4,4);
tspan = [0:0.01:1];
x30 = 1;
x40 = 2;
x0 = [0;0;x30;x40];
[t,x] = ode45(@(t,x)A*x,tspan,x0);
plot(x(:,1),x(:,2))
xlabel('x_1')
ylabel('x_2')
title(' phase portrait ')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!