How to draw the direction field of van der pol oscillator?

조회 수: 8 (최근 30일)
Gopichandh Danala
Gopichandh Danala 2017년 3월 23일
답변: KSSV 2017년 3월 23일
Hi, I am trying to get the direction field and phase portrait shown on this wiki page:
My code:
options = odeset('MaxStep',0.5);
temp = inputdlg('Enter mu value');
mu = str2double(temp{1,1});
[t,y] = ode45(@(t,y) vdp1_1(t,y,mu),[0 10],[2; 0],options);
figure(1);
plot(t,y(:,1)),
xlabel('time t');
ylabel('Y1(t)');
title('t vs Y1(t)');
figure(2);
plot(t,y(:,2))
xlabel('time t');
ylabel('Y2(t)');
title('t vs Y2(t)');
figure(3),
plot(y(:,1),y(:,2)) , hold on
quiver(y(:,1), y(:,2), gradient(y(:,1)), gradient(y(:,2) ))
hold off
function dydt = vdp1_1(t,y,mu)
dydt = zeros(2,1);
dydt(1) = y(2);
dydt(2) = [mu * (1-y(1)^2)*y(2)-y(1)];
end
Output
Desired output: How to get the direction field on top of this as shown in the wiki page figure https://en.wikipedia.org/wiki/Van_der_Pol_oscillator#/media/File:VanDerPolOscillator.png
Thanks, Gopi

답변 (1개)

KSSV
KSSV 2017년 3월 23일

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by