assignment2 de

4
Name___________________________________ Matrix______________________ H/P_______________________ Subject: KE26503 Assignment 2 MATLAB m-file (with graph for solution) Second order linear and non-homogeneous differential equation: d 2 y/dt 2 + 3dy/dt + 2y = cos2t KE26503 Differential Equations 1415(1) Assignment #2

Upload: nurulanisahmad

Post on 13-Nov-2015

214 views

Category:

Documents


0 download

DESCRIPTION

differential equations

TRANSCRIPT

Name___________________________________ Matrix______________________ H/P_______________________ Subject: KE26503Name___________________________________ Matrix____________________ H/P:___________________ Subject: KE00103 / KS20303 / KA / KMAssignment 2

MATLAB m-file (with graph for solution) Second order linear and non-homogeneous differential equation:d2y/dt2 + 3dy/dt + 2y = cos2t

MATLAB-SIMULINK (with graph for solution)

(a) Discussion of all the methods and solution

MATLAB m-fileFor example, in order to solve the second order equation:d2y/dt2 + 3dy/dt + 2y = cos2t with y(0) = 0 and dy/dt t=0 = 1for 0 t 10 we must define a variable x such that:x = dy/dtThus we can rewrite the differential equation as:d2y/dt2 = 3dy/dt 2y + cos2t or in terms of x: dx/dt = 3x 2y + cos2tWe will use the ode45 command to solve the system of first order differential equations:dx/dt = 3x 2y + cos2tdy/dt = xWe place these two equations into a column vector, z, where:

z = xdz /dt = dx / dt y dy /dt

A function is created in a MATLAB m-file to define dz/dt named f2 which contains:function dz=f2(t,z)dz=[-3*z(1)-2*z(2)+cos(2*t); z(1)];>> initz=[1; 0];and the equations are solved and plotted using:>> [t,z]=ode45(@f2, t, initz);>> plot(t, z(:,2))

MATLAB-SIMULINK

The second order differential equation, d2y/dt 2 + 3dy/dt + 2y = cos2t in Simulink. This equation can be re-written as, d2y/dt 2 = 3dy/dt 2y + cos2t. In order to get the three input subtractor, use the two input subtractor.In order to get y and dy/dt we need to integrate the output of this summer twice. Simulate the circuit for 10 seconds

KE26503 Differential Equations 1415(1) Assignment #2KE00103 / KS20303 Differential Equations 0910(2) Test #2