Solution of ordinary differential Equation

 

OBJECTIVE

  • To solve ordinary differential Equation

LEARNING OUTCOMES

  • After the completion of this experiment students will be able to solve  ordinary differential Equation

SOFTWARE USED:

                 MATLAB® R2017a

 

1. Solve the first order differential equation

With initial condition x(0)=1

Program

syms x(t);

eqn= diff(x,t)+ 2*x ==0;

cond= x(0)==1;

soln= dsolve(eqn,cond)

t=0:0.05:10

s=subs(soln)

plot(s)

title('Response of firt order differential equation')

xlabel('time')

Output

soln =

exp(-2*t)

2. solve second order differential equation

Program

syms x(t) ;

eqn= diff(x,t,2) + 2*diff(x,t) + 2*x  == exp(-t);

soln= dsolve(eqn);

soln=simplify(soln)

OUTPUT

soln = exp(-t)*(C4*cos(t) + C5*sin(t) + 1)

 

3. Solve the differential equation

cos(2*x)-y

y(0)=1

y’(0)=0

PROGRAM

syms y(x)

Dy = diff(y);

ode = diff(y,x,2) == cos(2*x)-y;

cond1 = y(0) == 1;

cond2 = Dy(0) == 0;

conds = [cond1 cond2];

ySol = dsolve(ode,conds);

ySol = simplify(ySol)

OUTPUT

1 - (8*sin(x/2)^4)/3

4.  Solve for the current transient through an RC network (with RC = 3) that is driven by

(a) 5V DC

(b) The signal

and plot the solutions.

(a) PROGRAM

clc;

clear all;

close all;

syms i(t);

V=5;

R=3;

C=1;

eqn=  diff(i,t)+ i/(R*C) ==0;

cond= i(0)==V/R;

soln= dsolve(eqn,cond)

  t=0:.05:10;

  s=subs(soln);

  plot(t,s,'k', 'linewidth',2)

title('Current Transient of RC circuit');

xlabel('time');

ylabel('Current through capacitor');

 OUTPUT


(b) PROGRAM

 clc;

clear all;

close all;

syms i(t);

V=5*exp(-t);

R=3;

C=1;

eqn=  diff(i,t)+ i/(R*C) ==diff(V,t)/R;

cond= i(0)==5/R;

soln= dsolve(eqn,cond)

  t=0:.05:10;

  s=subs(soln);

  plot(t,s,'k', 'linewidth',2)

title('Current Transient of RC circuit');

xlabel('time');

ylabel('Current through capacitor');

OUTPUT


5.  Solve for the voltage across the capacitor of an  RC network that is driven by 5V DC, with three different time constants.

PROGRAM

clc;

clear all;

close all;

syms vc(t);

V=5;

R1=3; %RC time constant = 3

C1=1;

TC1=R1*C1;%Time constant

eqn=  diff(vc,t)==(V-vc)/(TC1);

cond= vc(0)==0;

soln1= dsolve(eqn,cond)

 

TC2=2*TC1;%2 times the Time constant

eqn=  diff(vc,t)==(V-vc)/(TC2);

soln2= dsolve(eqn,cond)

 

TC3=3*TC1;%3 times the Time constant

eqn=  diff(vc,t)==(V-vc)/(TC3);

soln3= dsolve(eqn,cond)

 

t=0:.05:20;

s1=subs(soln1);

s2=subs(soln2);

s3=subs(soln3);

plot(t,s1, 'r', 'linewidth',2);

hold on;

plot(t,s2, 'g', 'linewidth',2);

hold on;

plot(t,s3, 'k', 'linewidth',2);

legend('RC','2*RC','3*RC');

title('Voltage Transient of RC circuit');

xlabel('time');

ylabel('Voltage across capacitor'); 

OUTPUT


6. Solve the current transient through a series RLC circuit with R = 9, L = 1H and C = 0.05 F that is driven by

(a) 20 V DC

(b) The signal


and plot the solutions

 

(a) PROGRAM

clc;

clear all;

close all;

syms i(t);

V=20;

R1=9;

L1=1;

C1=0.05;

Di=diff(i);

eqn1=  diff(i,t,2)+(R1/L1)*diff(i,t)+(1/(L1*C1))* i ==0;

cond1=[i(0)==0, Di(0)==20];

soln1= dsolve(eqn1, cond1);

t=0:.005:5;

s1=subs(soln1);

plot(t,s1,'r', 'linewidth',2);

title('Current Transient through RlC circuit');

xlabel('time');

ylabel('Current through the circuit');


OUTPUT



(b) PROGRAM

clc;

clear all;

close all;

syms i(t);

V=20*exp(-t);

R1=9;

L1=1;

C1=0.05;

Di=diff(i);

eqn1=  diff(i,t,2)+(R1/L1)*diff(i,t)+(1/(L1*C1))* i ==(1/L1)*diff(V,t);

cond1=[i(0)==0, Di(0)==20];

soln1= dsolve(eqn1, cond1);

t=0:.005:5;

s1=subs(soln1);

plot(t,s1,'r', 'linewidth',2);

title('Current Transient through RlC circuit');

xlabel('time');

ylabel('Current through the circuit');

OUTPUT




Comments

Popular posts from this blog

Teaching Stuff

NUMERICAL DIFFERENTIATION AND INTEGRATION

FAMILIARIZATION OF THE COMPUTING TOOL