0

我想为许多 epsilon 绘制 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 方程图。不太确定如何做到这一点,任何帮助将不胜感激。

4

1 回答 1

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
于 2013-03-07T15:37:56.487 回答