用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0,y(1)=2,y(2)=0,[0,20],麻烦把程

学习 时间:2026-03-31 19:04:20 阅读:1738
用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0,y(1)=2,y(2)=0,[0,20],麻烦把程序编出来用matlab求这个方程的数值解:y''-(1-y^2)y'+y=0,y(1)=2,y(2)=0,[0,20],麻烦把程序编出来

最佳回答

无心的毛衣

害羞的长颈鹿

2026-03-31 19:04:20

这是你们老师出的题目吧,这个例子在好多书上都出现过。
具体如下:
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')

最新回答共有2条回答

  • 害羞的短靴
    回复
    2026-03-31 19:04:20

    这是你们老师出的题目吧,这个例子在好多书上都出现过。具体如下: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。Theresulting 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 viewthe solver output:plot(t,y(:,1),'-',t,y(:,2),'--')xlabel('time t');ylabel('solution y');legend('y_1','y_2')

上一篇 从动物植物身上得到启示我想发明什么 作文

下一篇 写出下面单词的过去式thank----- see------ will------- draw----- sing---