使用MATLAB我试图绘制人类epsilons的van der pol方程?

时间:2013-03-07 15:31:40

标签: matlab plot

我想为许多epsilons的van der Pol方程绘制解决方案,我的代码是:

tspan = [0, 10];
y0 = [0.5; 0];  % Initial location

for ep = 0.1:0.2:2.5  % Loop through a few epsilons
    ode = @(t,y) vanderpol(t,y,ep);   % Call vanderpol.m for the points (t,y)
    [t,y] = ode45(ode, tspan, y0);    % solve Van der Pol equation

    % Plot of the solution

    plot(t,y(:,1)); drawnow;
    %xlabel('Time');
    %ylabel('Van der Pol Solution');
    %title('Solutions to van der Pol equation for many \epsilon');
end

我想要每个图上每个epsilon的van der Pol方程图。不确定如何做到这一点任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

使用figure创建不同的图表:

tspan = [0, 10];
y0 = [0.5; 0];  % Initial location

for ep = 0.1:0.2:2.5  % Loop through a few epsilons
    ode = @(t,y) vanderpol(t,y,ep);   % Call vanderpol.m for the points (t,y)
    [t,y] = ode45(ode, tspan, y0);    % solve Van der Pol equation

    % Plot of the solution

    figure,  

    plot(t,y(:,1)); drawnow;
    %xlabel('Time');
    %ylabel('Van der Pol Solution');
    %title('Solutions to van der Pol equation for many \epsilon');
end

单个地块使用hold on

tspan = [0, 10];
y0 = [0.5; 0];  % Initial location

for ep = 0.1:0.2:2.5  % Loop through a few epsilons
    ode = @(t,y) vanderpol(t,y,ep);   % Call vanderpol.m for the points (t,y)
    [t,y] = ode45(ode, tspan, y0);    % solve Van der Pol equation

    % Plot of the solution

    plot(t,y(:,1)); drawnow;
    %xlabel('Time');
    %ylabel('Van der Pol Solution');
    %title('Solutions to van der Pol equation for many \epsilon');
    hold on
end