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

4 次查看(过去 30 天)
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 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by