function Lab3_prob3 clear; clc; close all; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Problem 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% % 1(c) %%%%%%%%%%%%%% % Defining a 1st order ODE function dy=myODE(t,y) dy=-y+5*heaviside(t-2).*exp(-0.01*(t-1)); end % Initial condition y0=3; % time interval t=0:0.1:10; % Solving the ODE [t,y1]=ode45(@myODE, t, y0); %Defining a direction field of the ODE [x,y]=meshgrid(t,-0.5:.1:5); dy = myODE(x,y); dx = ones(size(dy)); dyu = dy./sqrt(dx.^2+dy.^2); dxu = dx./sqrt(dx.^2+dy.^2); figure; % Plotting the solution of the ODE plot(t,y1, 'LineWidth', 3) hold on; % Plotting the direction field quiver(x,y,dxu,dyu) legend('solution of 1st order ode') %%%%%%%%%%%%%% % 1(e) %%%%%%%%%%%%%% %Finding the Laplace Transform of a function t=sym('t'); f= heaviside(t-3)-heaviside(t-5) laplace(f) %Finding the Inverse Laplace Transform of a function clear; s=sym('s'); %%%%%% Modify this to answer 1(e) F = 1/(s+5)+2*(exp(-2*s))/((s+5)*(s+1)) ilaplace(F) figure; ezplot(ilaplace(F),[0,10]), axis square, grid on end