I have an ODE
dy=x dx, y(0)=2
The solution of this equation is 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
My code is 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
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.