assignment differential equations

4
Name___________________________________ Matrix______________________ H/P_______________________ Subject: KE26503 Assignment1 MATLAB m-file (with graph for solution) First order non-linear and non-homogeneous dy/dt + 2y = u(t) − u(t − 1) KE26503 Differential Equations 1415(1) Assignment #1

Upload: nurulanisahmad

Post on 28-Sep-2015

220 views

Category:

Documents


0 download

DESCRIPTION

differential equations

TRANSCRIPT

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

MATLAB m-file (with graph for solution)First order non-linear and non-homogeneousdy/dt + 2y = u(t) u(t 1)

MATLAB-SIMULINK (with graph for solution)

Discussion of all the methods and solution MATLAB m-fileIn this example we will solve the first order differential equation:dy/dt + 2y = u(t) u(t 1)over the range 0 t 5. We will assume that the initial value y(0) = 0. The first step isto write the equation in the form:

dy/dt = 2y + u(t) u(t 1)Next we need to create a MATLAB m-file to calculate dy/dt. Enter the following:function dy = f(t,y)dy = -2*y + (t>=0)-(t>=1);

This creates a function that calculates the value of dy (actually dy/dt). Once the function for dy/dt has been created we need to specify the end points of the time range (0 t 5) and the initial value of y (zero). This is done in the MATLAB commandwindow with the following commands:>> t= [0 5];>> inity=0;The ode45 command can now be called to compute and return the solution for y alongwith the corresponding values of t using:>> [t,y]=ode45(@f, t, inity);Note that the @f refers to the name of the function containing the function. The solutioncan be viewing with:>> plot(t,y)

MATLAB-SIMULINKUse Simulink to model the differential equations solved.

dy/dt + 2y = u(t) u(t 1)First we need to simulate the single one-second pulse. Since the simulation will run for0t5, we can use the pulse generator to generate a five second pulse with a 1 secondpulse width. Specify fixed-step samples of 0.01 seconds. .

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