Clear Filters
Clear Filters

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

4 views (last 30 days)
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

Answers (1)

KSSV
KSSV on 23 Mar 2017

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!