Solve and plot the phase portrait for van der pol ODE with time dependent term

조회 수: 9 (최근 30일)
F.O
F.O 2019년 3월 27일
댓글: Rena Berman 2019년 4월 2일
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
  댓글 수: 4
Jan
Jan 2019년 3월 31일
And now all visitors of this page see this junk: "Solve mmmmmmmmmm​mmmmmmmmmm​mmmmmmmmmm" and "kkklllllll". Come on, F.O, you can see, that leaving junk in the forum is not useful.
The nature of the forum is the sharing of solutions. So explain your solution in an own answer and accept it, instead of inserting nonsense. Imagine how hillarious this forum would look like, if all users roll an angry armadillo over the keyboard, when their problem is solved.

댓글을 달려면 로그인하십시오.

답변 (1개)

madhan ravi
madhan ravi 2019년 3월 27일
편집: madhan ravi 2019년 3월 27일
g,lambda
%^—-missed it
Don’t name variable lambda (will shadow in-built function gamma())
  댓글 수: 1
madhan ravi
madhan ravi 2019년 3월 27일
편집: madhan ravi 2019년 3월 27일
After someone answers the question it’s not appropriate to edit the question!! You have some problems with declaring the input arguments while calling the function, analyse slowly and observe what obvious mistake you made.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by