如何绘制范德波尔振荡器的方向场? [英] How to draw the direction field of van der pol oscillator?

查看:124
本文介绍了如何绘制范德波尔振荡器的方向场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取此Wiki页面上显示的方向场和相像:

I am trying to get the direction field and phase portrait shown on this wiki page:

维基百科中的Van der Pol振荡器

我的代码:

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);
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

电流输出:

所需的输出: 如何获得方向字段的顶部,如Wiki页面图

Desired Output: How to get the direction field on top of this as shown in the wiki page figure

谢谢,
戈皮

推荐答案

您需要在要显示箭头的每个点上计算矢量场.然后用颤动器绘制该图.例如.

You need to calculate the vector field at every point you want an arrow to be shown. And then you plot this with quiver. For example.

[Xs,Ys]=meshgrid(-5:5,-5:5); % Will define the positions where we want to plot

Us=Ys; % From your equations, these are the values of the field at each point
Vs=mu*(1-Xs.^2).*Ys-Xs;

quiver(Xs,Ys,Us,Vs) % Should plot the field you want, just add the trajectory on top

这篇关于如何绘制范德波尔振荡器的方向场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆