Sunday, May 17, 2015

Matlab code to Solve the 2nd order differential equation y''-2y'-3y=e^2t

close all;

clc;

%% Solve the 2nd order differential equation y''-2y'-3y=e^2t

%% y' can be represented using 'D' or diff and y'' can be 

%% represented using 'D2y'

%% For 2nd order differential equation provide 2 initial condition

y=dsolve('D2y-2*Dy-3*y=exp(2*t)','y(0)=1','Dy(0)=2','t')

%% Make Y pretty

pretty(y)

%% Plot the expression at diffrent value of x

%% ezplot-> y is a function with respect to x
%% only plot --> x and y has some values

ezplot(y,[0 50])

No comments:

Post a Comment