[英]Octave program to solve ODE
I have an ODE 我有一个ODE
dy=x dx, y(0)=2
The solution of this equation is y =x^2/2 + K.
该方程的解为y =x^2/2 + K.
K become 2.
Now I have to plot graph. 现在我要绘制图形。 When 什么时候
x=0, y=2
x=1, y=2.5
x=2, y=4
x=3, y=6.5
x=4, y=10
I have to write an Octave program
to generate these values 我必须编写一个Octave program
来生成这些值
My code is test.m 我的代码是test.m
function xdot = f (x,t)
xdot=x;
endfunction
x=lsode("f",2,(t=linspace(0,4,5)));
#plot(t,x)
x
I run the pgm in cmd but it gives 我在cmd中运行pgm但它给
2.0000
5.4366
14.7781
40.1711
109.1963
The expected result is 预期的结果是
2
2.5
4
6.5
10
Please help me.. 请帮我..
Finally got the answer.. 终于得到答案了。
Use 采用
xdot=t;
instead of 代替
xdot=x;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.