Draw the vector field and eigenvectors in the phase portrait for Van der Pol ODE
이전 댓글 표시
I have the follwing system which represent the Van der Pol oscillator with the inital condition and parameters are given. I draw the phase porrait using plot and ode45 but dont know how to draw the vector field and the eigenvectors with direction on them.

%function to solve the system with the time dependent term zero
function [dxdt] = vdp1(t,x,lambda,gamma,omega)
dxdt=zeros(2,1);
dxdt(1)=x(2);
dxdt(2)=lambda.*(1-x(1)^2)*x(2)-x(1)+gamma.*sin(omega*t);
end
%function to solve the system with the time dependent not zero
function [dxdt] = myode(t,x,gt,g,lambda,gamma,omega)
g=interp1(gt,g,t);
dxdt=zeros(2,1);
dxdt(1)=x(2);
dxdt(2)=lambda.*(1-x(1)^2)*x(2)-x(1)+g;
end
%script
lambda=[0.01 0.1 1 10 100] ;
gamma=[0 0.25];
omega=[0 1.04 1.1];
x0=[1 0];
x01=[3 0];
tspan=[0 500];
tspan1=[0 100];
%Numerical solution for the first initial value
[t,x]=ode45(@(t,x) vdp1(t,x,lambda(1),gamma(1),omega(1)),tspan,x0);
%Numerical solution for the second initial value
[t1,x1]=ode45(@(t,x) vdp1(t,x,lambda(1),gamma(1),omega(1)),tspan,x01);
%plotting x1,x2 aginst t
figure(3)
plot(x(:,1),x(:,2),'g-.')
hold on;
plot(x1(:,1),x1(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 500] ,gamma=0,omega=0,lambda=0.01')
[tt1,xx1]=ode45(@(t,x) vdp1(t,x,lambda(2),gamma(1),omega(1)),tspan1,x0);
[tt2,xx2]=ode45(@(t,x) vdp1(t,x,lambda(3),gamma(1),omega(1)),tspan1,x0);
[tt3,xx3]=ode45(@(t,x) vdp1(t,x,lambda(4),gamma(1),omega(1)),tspan1,x0);
[tt4,xx4]=ode45(@(t,x) vdp1(t,x,lambda(5),gamma(1),omega(1)),tspan1,x0);
[tt11,xx11]=ode45(@(t,x) vdp1(t,x,lambda(2),gamma(1),omega(1)),tspan1,x01);
[tt22,xx22]=ode45(@(t,x) vdp1(t,x,lambda(3),gamma(1),omega(1)),tspan1,x01);
[tt33,xx33]=ode45(@(t,x) vdp1(t,x,lambda(4),gamma(1),omega(1)),tspan1,x01);
[tt44,xx44]=ode45(@(t,x) vdp1(t,x,lambda(5),gamma(1),omega(1)),tspan1,x01);
figure(6)
plot(xx1(:,1),xx1(:,2),'g-.')
hold on;
plot(xx11(:,1),xx11(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 100] ,gamma=0,omega=0,lambda=0.1')
figure(8)
plot(xx2(:,1),xx2(:,2),'g-.')
hold on;
plot(xx22(:,1),xx22(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 100] ,gamma=0,omega=0,lambda=1')
figure(10)
plot(xx3(:,1),xx3(:,2),'g-.')
hold on;
plot(xx33(:,1),xx33(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 100] ,gamma=0,omega=0,lambda=10')
figure(12)
plot(xx4(:,1),xx4(:,2),'g-.')
hold on;
plot(xx44(:,1),xx44(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 100] ,gamma=0,omega=0,lambda=100')
gt=[0 500];
g=gamma(2).*sin(omega(2).*gt);
g1=gamma(2).*sin(omega(3).*gt);
opts = odeset('RelTol',1e-2,'AbsTol',1e-4);
[t2,x2]=ode45(@(t,x) myode(t,x,gt,g,lambda(1),gamma(2),omega(2)),tspan,x0,opts);
[t22,x22]=ode45(@(t,x) myode(t,x,gt,g,lambda(1),gamma(2),omega(2)),tspan,x01,opts);
[t3,x3]=ode45(@(t,x) myode(t,x,gt,g,lambda(1),gamma(2),omega(3)),tspan,x0,opts);
[t33,x33]=ode45(@ (t,x) myode(t,x,gt,g1,lambda(1),gamma(2),omega(3)),tspan,x01,opts);
figure(14)
plot(x2(:,1),x2(:,2),'g-.')
hold on;
plot(x22(:,1),x22(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 500] ,gamma=0.25,omega=1.04,lambda=0.01')
figure(16)
plot(x3(:,1),x3(:,2),'g-.')
hold on;
plot(x33(:,1),x33(:,2),'r-.')
xlabel('x1');
ylabel('x2')
legend('Solution first initial condition','Solution with the second initial condition')
title('phase portrait with t=[0 500] ,gamma=0.25,omega=1.1,lambda=0.01')
댓글 수: 9
Jan
2019년 3월 31일
I'm not going to post an answer as long as you delete questions after answers have been given. Please participate fairly in the forum.
F.O
2019년 3월 31일
John D'Errico
2019년 3월 31일
You did not even give people a chance to answer your last question.
Jan
2019년 3월 31일
@F.O: The forum reacts allergic to users, who overwrite their questions with "kkklllllll" and "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm". If somebody does this, he or she is obviously aware, that a standard deleting is not possible and wanting. Then replacing the contents with junk is not a fair usage of the forum.
It is another problem, that your question was deleted during you edited it. Here I agree with you that it is better to ask "what have you done so far" instead of deleting the question. You hzave provided your code and there is no doubt that you have spent effort to soolve your problem.
@Editor, who has deleted the former question of F.O: Please post a comment instead of deleting a question too fast.
F.O
2019년 3월 31일
Jan
2019년 3월 31일
This works here also: Simply add a comment or a flag and ask for deleting. The editors and admins will care for this as long as no answers have been given.
F.O
2019년 3월 31일
F.O
2019년 4월 2일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!