12 views (last 30 days)

I want to solve this system of ode by ode45 and then plot the x1 and x2 with t and phase portrait later but I got error which i couldint figure out

How i could draw the vector field and eigen vectors in the phase portrait because i dont get by using ode set and odephase 2

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

gamma=0.25;

omega=[1.04 1.1];

gt=[0 ,500]

g=gamma.*sin(omega(1).*gt)

% g=gamma.*sin(omega(2).*gt)

lambda=0.01;

x0=[1 0]

tspan=[0 500];

opts = odeset('RelTol',1e-2,'AbsTol',1e-4);

[t2,x2]=ode45(@(t,x) myode(t,x,gt,g,gt,lambda,gamma,omega(1)),tspan,x0,opts);

% ploting the phase portait

function PLOT_VDP()

figure(1)

options=odeset('OutputFcn', @odephas2);

lambda=0.01;

gamma=0.25;

omega=[1.04 1.1];

x0=[1; 0]

x01=[3;0]

tspan=[0 500];

[t,x]=ode45(@(t,x) myode(t,x,g,lambda,gamma,omega(1)),tspan,x0,options);

end

madhan ravi
on 27 Mar 2019

Edited: madhan ravi
on 27 Mar 2019

g,lambda

%^—-missed it

Don’t name variable lambda (will shadow in-built function gamma())

madhan ravi
on 27 Mar 2019

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_687945

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_687945

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_688150

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_688150

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_688169

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_688169

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_689070

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/452772-solve-and-plot-the-phase-portrait-for-van-der-pol-ode-with-time-dependent-term#comment_689070

Sign in to comment.