用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0, y(1)=2,y(2)=0,x?[0,20],麻烦把程序编出来
用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0,y(1)=2,y(2)=0,x?[0,20],麻烦把程序编出来...
用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0,
y(1)=2,y(2)=0,x?[0,20],麻烦把程序编出来 展开
y(1)=2,y(2)=0,x?[0,20],麻烦把程序编出来 展开
3个回答
展开全部
这是你们老师出的题目吧,这个例子在好多书上都出现过。
具体如下:
function dydt = vdp1(t,y)
dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
end
保存函数文件
[t,y] = ode45(@vdp1,[0 20],[2; 0]);
%This example uses @ to pass vdp1 as a function handle to ode45. The
resulting output is a column vector of time points t and a solution array y.Each row in y corresponds to a time returned in the corresponding row of t.
作图:
You can simply use the plot command to view
the solver output:
plot(t,y(:,1),'-',t,y(:,2),'--')
xlabel('time t');
ylabel('solution y');
legend('y_1','y_2')
具体如下:
function dydt = vdp1(t,y)
dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
end
保存函数文件
[t,y] = ode45(@vdp1,[0 20],[2; 0]);
%This example uses @ to pass vdp1 as a function handle to ode45. The
resulting output is a column vector of time points t and a solution array y.Each row in y corresponds to a time returned in the corresponding row of t.
作图:
You can simply use the plot command to view
the solver output:
plot(t,y(:,1),'-',t,y(:,2),'--')
xlabel('time t');
ylabel('solution y');
legend('y_1','y_2')
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询