help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Octave program to solve ODE


From: deepus
Subject: Octave program to solve ODE
Date: Mon, 27 Jul 2015 03:38:00 -0700 (PDT)

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..



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Octave-program-to-solve-ODE-tp4671842.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]