Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

PRACTICLE NO:- 8

Q. Find the numerical solution of following differential equation dx/dt=


t-0.1x^2 with initial condition x0=1 in the range 0<= t <=0.8 and draw
the graph of the solution by using ode 23 solver.

Ans:-
command
M file:-
function xdot=f(t,x)
xdot=t-0.1*x^2;

command window

>> tspan=[0 0.8];


>> x0=1;
>> [t,x]=ode23('f3',tspan,x0)

solution

t=

0
0.0800
0.1600
0.2400
0.3200
0.4000
0.4800
0.5600
0.6400
0.7200
0.8000

x=

1.0000
0.9952
0.9969
1.0049
1.0191
1.0395
1.0658
1.0980
1.1361
1.1798
1.2290

Graph of solution to the differential equation dx = t-0.1x^2


dt

>> plot(t,x);
>> xlabel(' t');
>> ylabel('x');
>> title('Graph of solution');

Graph of solution
1.25

1.2

1.15

1.1
x

1.05

0.95
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
t

You might also like