Chapter 6 The Laplace Transform
Chapter 6 The Laplace Transform
clear, clc
hold on
grid on
xlabel 't', ylabel 'f(t)'
t = 0:0.01:1;
plot(t,t.^2)
t = 1.01:0.01:2;
plot(t,2+t)
t = 2.01:0.01:3;
plot(t,6-t,'g')
legend('t^2','2+t','6-t', ...
'Location','northwest')
clear, clc
hold on
grid on
ylim([0 5]) % set vert axis range
xlabel 't', ylabel 'f(t)'
t = 0:0.01:1;
plot(t,t.^2)
t = 1.01:0.01:2;
plot(t,(t-1).^-1)
t = 2.01:0.01:3;
plot(t,t./t,'g')
legend('t^2','(t-1)^-1','1', ...
'Location','northwest')
clear, clc
hold on
grid on
ylim([0 1.5]) % set vert axis range
xlabel 't', ylabel 'f(t)'
t = 0:0.01:1;
plot(t,t.^2)
t = 1.01:0.01:2;
plot(t,t./t)
t = 2.01:0.01:3;
plot(t,3-t,'g')
legend('t^2','1','3-t', ...
'Location','northwest')
clear, clc
syms s a t
f = int(exp(-s*t)*t^2*sin(a*t),t);
collect(f, [cos(a*t) sin(a*t)])
6.2 Solution of Initial Value Problems
clear, clc
syms s
f = 2/(s^2 + 3*s -4)
partfrac(f)
clear, clc
syms s
f = (8*s^2 - 4*s + 12)/(s*(s^2 + 4))
partfrac(f)
clear, clc
syms s
f = (s-2)/((s-3)*(s+2))
partfrac(f)
clear, clc
syms s
f = (s+3)/((s+2)*(s+1))
partfrac(f)
clear, clc
syms s
factor(s^4 - 4*s^3 + 6*s^2 - 4*s +1)
clear, clc
syms s
f = (s^2 - 4*s + 7)/(s-1)^4
partfrac(f)
clear, clc
syms s
f = 1/((s+1)*(s^2 - 2*s + 2))
partfrac(f)
clear, clc
syms t
f(t) = sin(t)/t;
for n = 1:8
df=diff(f,t,n);
limit(df,t,0)
end
6.3 Step Functions
clear, clc
syms t g
g = heaviside(t-1) + ...
2*heaviside(t-3) - ...
6*heaviside(t-4);
fplot(g)
xlim([0 5]);
ylim([-4 4]);
grid on
title('g(t) = u1(t) + 2*u3(t) - 6*u4(t)')
xlabel 't', ylabel 'g(t)'
clear, clc
figure
hold on
xlim([0 5]);
ylim([-4 4]);
grid on
clear, clc
figure
hold on
xlim([0 5]);
ylim([-1.2 1.2]);
grid on
t = 0:0.01:1-0.01;
plot(t, 0*t) % plot 0
t = 1:0.01:2-0.01;
plot(t, t-1) % t-1 on [1,2]
t = 2:0.01:3-0.01;
plot(t, (t-1) - 2*(t-2)) % on [2,3]
t = 3:0.01:5;
plot(t, (t-1) - 2*(t-2) + (t-3)) % on [3,5]
title('g(t) = (t-1)*u_1(t) - 2(t-2)*u_2(t) + (t-3)*u_3(t)')
xlabel 't', ylabel 'g(t)'
clear, clc
figure
hold on
x = [0, 9]; % xmin, xmax
xlim(x);
ylim([-3 3]);
grid on
int = [3, 5, 7]; % interval break points
t = 0:0.01:int(1)-0.01;
plot(t, 0*t) % plot 0
plot(int(1), 0, 'Marker',"o")
t = int(1):0.01:int(2)-0.01;
plot(t, 0*t - 2)
plot(int(2), -2, 'Marker',"o")
t = int(2):0.01:int(3)-0.01;
plot(t, 0*t + 2)
plot(int(3), 2, 'Marker',"o")
t = int(3):0.01:x(2);
plot(t, 0*t + 1)
t = 0:0.01:int(1)-0.01;
plot(t, 0*t + 1)
plot(int(1), 1, 'Marker',"o")
t = int(1):0.01:int(2)-0.01;
plot(t, 0*t - 1)
plot(int(2), -1, 'Marker',"o")
t = int(2):0.01:int(3)-0.01;
plot(t, 0*t + 1)
plot(int(3), 1, 'Marker',"o")
t = int(3):0.01:int(4)-0.01;
plot(t, 0*t - 1)
plot(int(4), -1, 'Marker',"o")
t = int(4):0.01:x(2);
plot(t, 0*t)
t = 0:0.01:int(1)-0.01;
plot(t, 0*t + 1)
%plot(int(1), 1, 'Marker',"o")
t = int(1):0.01:x(2);
plot(t, exp(-(t-2)))
t = 0:0.01:int(1)-0.01;
plot(t, t)
t = int(1):0.01:int(2)-0.01;
plot(t, 0*t + 2)
t = int(2):0.01:int(3)-0.01;
plot(t, 7 - t)
t = int(3):0.01:x(2);
plot(t, 0*t)
title('f(t) = 1 - u_1(t)')
xlabel 't', ylabel 'f(t)'
function PlotSawtooth(x)
t = x:0.01:x+1; % [0,1]
plot(t, t-x, '-b') % subtract x start value
t = x+1:0.01:x+2; % [1,2]
plot(t, 2-(t-x), 'b')
end
6.4 Differential Equations with Discontinuous Forcing Functions
clear, clc
figure
hold on
xlim([0 14]);
ylim([-0.5 1.5]);
grid on
PlotHzLine(0,pi,0)
PlotHzLine(pi,2*pi,1)
PlotHzLine(2*pi,15,0)
PlotHzLine(0,10,1)
PlotHzLine(10,15,0)
title('f(t) = 1 - u_1_0(t)')
xlabel 't', ylabel 'f(t)'
clear, clc
syms t
g(t) = 1/2 + (1/2)*exp(-2*t) - exp(-t);
y(t) = g(t) - heaviside(t-10)*g(t-10);
fplot(y(t), [0, 20])
grid on
ylim([-0.2, 0.8])
xlabel 't', ylabel 'y(t)'
title 'Solution to D_2y + 3D_1y +2y = f(t)'
clear, clc
syms t
f(t) = t - heaviside(t - pi/2)*(t - pi/2);
fplot(f(t), [0, 4])
grid on
ylim([-0.2, 2])
xlabel 't', ylabel 'f(t)'
title 't - u_p_i_/_2(t - pi/2)'
clear, clc
syms s
d = s^2*((s+1/2)^2 + 1)
partfrac(1/d)
clear, clc
syms t
g(t) = -16/25 + (4/5)*t + (1/25)*(exp(-t/2))*(16*cos(t)-12*sin(t));
y(t) = g(t) - heaviside(t - pi/2)*g(t - pi/2);
fplot(y(t), [0, 20])
grid on
ylim([-0.2, 2])
xlabel 't', ylabel 'y(t)'
title 'Solution to D_2y + D_1y + 5/4y = t - u_p_i_/_2(t) (t - pi/2)'
clear, clc
syms t
g(t) = sin(t) + heaviside(t-pi)*sin(t-pi);
fplot(g(t), [0, 3*pi])
grid on
ylim([-0.2, 1.2])
xlabel 't', ylabel 'g(t)'
title 'sin(t) - u_p_i(t-pi)*sin(t-pi)'
clear, clc
syms s
d = (s^2 + 1)*((s+1/2)^2 + 1)
partfrac(1/d)
clear, clc
syms t
h(t) = (4/17)*(-4*cos(t) + sin(t) + ...
4*exp(-t/2)*cos(t) + exp(-t/2)*sin(t));
y(t) = h(t) + heaviside(t-pi)*h(t-pi);
fplot(y(t), [0, 20])
grid on
ylim([-0.2, 1])
xlabel 't', ylabel 'y(t)'
title 'Solution to D_2y + D_1y + 5/4y = sin(t) + u_p_i(t) sin(t - pi)'
clear, clc
figure
hold on
xlim([0 14]);
ylim([-0.5 1.5]);
grid on
PlotHzLine(0,pi,0)
PlotHzLine(pi,3*pi,1)
PlotHzLine(3*pi,15,0)
PlotHzLine(0,pi,1)
PlotHzLine(pi,10,0)
title('f(t) = 1 - u_p_i(t)')
xlabel 't', ylabel 'f(t)'
PlotHzLine(0,3/2,0)
PlotHzLine(3/2,5/2,1)
PlotHzLine(5/2,15,0)
clear, clc
syms t
f = exp(-t)*(cos(t) + sin(t)) + ...
heaviside(t-pi)*exp(pi-t)*sin(t-pi);
fplot(f, [0,4*pi])
ylim([-0.1, 1.1])
hold on
xline(pi, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 2y'' + 2y = delta(t-pi), y(0)=1, y''(0)=0')
clear, clc
syms t
f = (1/2)*heaviside(t-pi)*sin(2*t) - ...
(1/2)*heaviside(t-2*pi)*sin(2*t);
fplot(f, [0,3*pi])
ylim([-0.6, 0.6])
hold on
xline(pi, 'color', 'r'); % show the impulse
xline(2*pi, 'color', 'r');
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 4y = delta(t-pi)-delta(t-2*pi), y(0)=0, y''(0)=0')
clear, clc
syms s
d = s*(s+2)*(s+1);
partfrac(1/d)
clear, clc
syms t
f = (1/2)*(exp(-t) - exp(-2*t)) + ...
heaviside(t-5)*(exp(-(t-5)) - exp(-2*(t-5))) + ...
heaviside(t-10)*(-exp(-(t-10)) + (1/2)*exp(-2*(t-10)) + 1/2);
fplot(f, [0,20])
ylim([-0.1, 0.6])
hold on
xline(5, 'color', 'r'); % show the impulse
xline(10, 'color', 'r');
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 3y'' + 2y = delta(t-5) + u_1_0(t), y(0)=0, y''(0)=1/2')
clear, clc
syms s
d = (s^2 + 1)*(s^2 + 2*s + 3);
partfrac(1/d)
clear, clc
syms t
a = sqrt(2);
f = (1/4)*(exp(-t)*cos(a*t) - cos(t) + sin(t)) ...
+(1/a)*heaviside(t-3*pi)*exp(3*pi-t)*sin(a*(t-3*pi));
fplot(f, [0,6*pi])
ylim([-0.6, 0.6])
hold on
xline(3*pi, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 2y'' + 3y = sin(t) + delta(t-3*pi), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
clear, clc
syms t
f = sin(t) + heaviside(t-2*pi)*sin(t);
fplot(f, [0,6*pi])
ylim([-2.1, 2.1])
hold on
xline(2*pi, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + y'' = delta(t-2*pi)cos(t), y(0)=0, y''(0)=1')
legend('y(t)', 'impulse', 'location', "southwest")
clear, clc
syms t
f = -heaviside(t-pi/4)*cos(2*t);
fplot(f, [0,3*pi])
ylim([-1.5, 1.5])
hold on
xline(pi/4, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + y'' = -u_p_i_/_4(t)cos(2t), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
clear, clc
syms s
d = (s^2 + 1)*(s^2 + 2*s + 2);
partfrac(s/d)
clear, clc
syms t
f = (1/5)*(cos(t) + 2*sin(t)) ...
- (1/5)*exp(-t)*(cos(t) + 3*sin(t)) ...
+ heaviside(t-pi/2)*exp(pi/2 - t)*sin(t-pi/2);
fplot(f, [0,4*pi])
ylim([-0.8, 0.8])
hold on
xline(pi/2, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 2y'' + 2y = cos(t) + delta(t-pi/2), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
clear, clc
syms t
f = (1/2)*heaviside(t-1)*(sinh(t-1) - sin(t-1));
fplot(f, [0,6])
ylim([-0.2, 10])
hold on
xline(1, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y"" - y = delta(t-1), y(0)=0, y''(0)=0, y"(0)=0, y(0)"''=0')
legend('y(t)', 'impulse', 'location', "southeast")
clear, clc
syms t
a = sqrt(15)/4;
t0 = 5 + 2*pi/a;
k = -exp(-2*pi/sqrt(15));
f(t) = (1/a)*exp(-t/4)*sin(a*t);
y = (1/2)*heaviside(t-5)*f(t-5) + (k/2)*heaviside(t-t0)*f(t-t0);
fplot(y, [0,2*t0-5])
ylim([-0.3, 0.5])
hold on
xline(5, 'color', 'r'); % show the impulses
xline(t0, 'color', 'r');
grid on
xlabel('t'), ylabel('y(t)')
title('2y" + y'' + 2y = delta(t-5) + k*delta(t-t0), y(0)=0, y''(0)=0')
legend('y(t)', 'impulses')
clear, clc
syms t
a = sqrt(15)/4;
y = (1/a)*heaviside(t-1)*exp(-(t-1)/4)*sin(a*(t-1));
fplot(y, [0, 1+5*pi])
ylim([-1, 1])
hold on
xline(1, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 1/2y'' + y = delta(t-1), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
clear, clc
tmesh = 0.0001; % indicate precision of times
t = 0:tmesh:5*pi; %create an array of times
a = sqrt(15)/4;
y = (1/a)*heaviside(t-1).*exp(-(t-1)/4).*sin(a*(t-1));
plot(t, y)
xlim([0,5*pi])
ylim([-1, 1])
hold on
xline(1, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 1/2y'' + y = delta(t-1), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
[ymax,tindex] = max(y)
tmax = (tindex-1)*tmesh % arrays are 1-based
clear, clc
tmesh = 0.0001; % indicate precision of times
t = 0:tmesh:6*pi; % create an array of times
a = 3*sqrt(7)/8;
y = (1/a)*heaviside(t-1).*exp(-(t-1)/8).*sin(a*(t-1));
plot(t, y)
xlim([0,6*pi])
ylim([-1, 1])
hold on
xline(1, 'color', 'r'); % show the impulse
grid on
xlabel('t'), ylabel('y(t)')
title('y" + 1/4y'' + y = delta(t-1), y(0)=0, y''(0)=0')
legend('y(t)', 'impulse')
[ymax,tindex] = max(y)
tmax = (tindex-1)*tmesh % arrays are 1-based
clear, clc
syms t
k = 0.25;
f = (1/(2*k)*(heaviside(t-(4-k))-heaviside(t-(4+k))));
fplot(f, [0,6])
ylim([-0.2, 2.2])
grid on
xlabel 't', ylabel 'f(t)'
title 'f(t) = 1/2k[u_4_-_k(t) - u_4_+_k(t)]'
clear, clc
syms t
phi0 = heaviside(t-4)*sin(t-4);
fplot(phi0)
hold on
h(t) = 1 - cos(t);
for k = [1/2, 1/4]
t1 = t - (4-k);
t2 = t - (4+k);
c = 1/(2*k);
phi = c*(heaviside(t1)*h(t1) - heaviside(t2)*h(t2));
fplot(phi)
end
xlim([0, 4 + 2.6*pi])
ylim([-1.1, 1.1])
grid on
xlabel 't', ylabel 'phi(t,k)'
title 'y" + y = 1/2k[u_4_-_k(t) - u_4_+_k(t)], y(0)=0, y''(0)=0'
legend('phi0(t)', 'phi(t, 1/2)', 'phi(t, 1/4)', 'location', "southwest")
clear, clc
syms t y
figure
hold on
y = 0;
for k = 1:20
y = y + heaviside(t-k*pi)*sin(t-k*pi);
xline(k*pi, 'color', 'r'); % show impulses
end
fplot(y)
xlim([0, 22*pi])
ylim([-0.2, 1.1])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + y = Sigma(delta(t-k*pi), y(0)=0, y''(0)=0'
legend('impulses', 'location', "southeast")
clear, clc
syms t y
y = 0;
for k = 1:20
y = y + ((-1)^(k+1))*heaviside(t-k*pi)*sin(t-k*pi);
end
fplot(y, [0, 24*pi])
ylim([-21, 21])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + y = Sigma((-1)^(^k^+^1^)delta(t-k*pi)), y(0)=0, y''(0)=0'
clear, clc
syms t y
y = 0;
for k = 1:15
y = y + heaviside(t-(2*k-1)*pi)*sin(t-(2*k-1)*pi);
end
fplot(y, [0, 32*pi])
ylim([-17, 17])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + y = Sigma(delta(t-(2k-1)*pi)), y(0)=0, y''(0)=0'
clear, clc
syms t y
y = 0; a = 11/4;
for k = 1:40
y = y + ((-1)^(k+1))*heaviside(t-a*k)*sin(t-a*k);
end
fplot(y, [0, 125])
ylim([-7, 7])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + y = Sigma((-1)^(^k^+^1^)delta(t-(11/4)k)), y(0)=0, y''(0)=0'
clear, clc
syms t y
y = 0; a = sqrt(399)/20;
h(t) = (1/a)*heaviside(t)*exp(-t/20)*sin(a*t);
for k = 1:20
y = y + ((-1)^(k+1))*h(t-k*pi);
end
fplot(y, [0, 38*pi])
ylim([-8, 8])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + 0.1y'' + y = Sigma((-1)^(^k^+^1^)delta(t-k*pi)), y(0)=0, y''(0)=0'
clear, clc
syms t y
y = 0; a = sqrt(399)/20;
h(t) = (1/a)*heaviside(t)*exp(-t/20)*sin(a*t);
for k = 1:15
y = y + h(t-(2*k-1)*pi);
end
fplot(y, [0, 50*pi])
ylim([-4, 4])
grid on
xlabel 't', ylabel 'y(t)'
title 'y" + 0.1y'' + y = Sigma(delta(t-(2k-1)*pi)), y(0)=0, y''(0)=0'
6.6 The Convolution Integral
clear, clc
syms s
d = s^4 + 5*s^2 + 4;
partfrac((s^3 + 5*s)/d)
clear, clc
syms s
d = (s^2 + 1)*(s^2 + 4);
partfrac(2*s^2/d)
clear, clc
syms s
d = (s+1)^3;
partfrac((s^2 + 1)/d)
clear, clc
syms s
d = (s+1)^2;
partfrac((s - 1)/d)
clear, clc
syms s
d = s^3 + 1;
partfrac(1/d)
clear, clc
a = 5; % arbitrarily assigned
th = 0:0.01:pi;
x = a*(th + sin(th));
y = a*(1 - cos(th));
plot(x,y)
grid on
xlabel 'x', ylabel 'y'