教授再问一下 也是数值分析的
引用了MATLAB的函数ode23这个列向量为yprime。同样,y1和y2合并写成列向量y。所得函数M文件是:
function yprime=vdpol(t , y);
% VDPOL(t , y) returns derivatives of the Van der Pol equation:
%
% x ‘‘-mu *(1-x ^2)*x ‘+x=0 (‘ = d/dx , ‘‘ = d^2/dx^2)
%
% let y(1)=x and y(2)=x‘
%
% then y(1) ‘ = y(2)
% y(2) ‘ = MU*(1-y(1)^2)*y(2)-y(1)
global MU % choose 0<MU<10 in Command workspace
yprime=[y(2) MU*(1-y(1)^2)*y(2)-y(1)]; % output must be a column
计算结果如下:
>>global MU % define MU as a global variable in the Command Workspace
>>MU=2; % set global parameter to desired value
>>[t , y]=ode23(‘ vdpol ’ , 0 , 30 , [1 ; 0]); % to=0 , tf=30 , yo=[1 ; 0]
>>y1=y( : , 1); % first column is y(1) versus time points in t
>>y2=y( : , 2); % second column is y(2)
>>plot(t , y1 , t , y2 , ‘ -- ‘)
>>xlabel(‘ Time , Second ‘) , ylabel(‘ Y(1) and Y(2) ‘)
>>title(‘ Van der Pol Solution for mu=2 ‘)
前面是对的 按例应该可以出图的 (后面有问题)
[t , y]=ode23(‘ vdpol ‘ , 0 , 30 , [1 ; 0]); % to=0 , tf=30 , yo=[1 ; 0]
我替换成了[t , y]=ode23(‘vdpol ’, [0 , 30] , [1 , 0]);
但是后面还是有错
能帮我看下指导下吗?