PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

64 Practical MATLAB® Applications for Engineers


Example 1.7

Create the script fi le analog_plots that returns the plot of each of the real value exponen-
tial signals shown as follows over the range − 5 ≤ t ≤ 6.

a. f 1 (t) = e–tu(t)
b. f 2 (t) = e–^1
c. f 3 (t) = f 1 (–t)
d. f 4 (t) = – e–tu(t)
e. f 5 (t) = f 2 (t). [(u(t – 2) – u(t – 3))]
f. f 6 (t) = f 1 (t) + f 1 (–t)
g. f 7 (t) = f 5 (t – 1)
h. f 8 (t) = f 4 (t) + [(u(t – 2) – u(t – 3)]

MATLAB Solution
% Script file: analog _ plots
t = -6:0.01:6;
t0 = 0;
u0 = stepfun(t, t0);
f1 = exp(-t).*u0;
f2 = exp(-t);
f3 = fliplr(f1);
tt = fliplr(t);
f4 = -1.*f1;

figure(1)
subplot(2,2,1);
plot(t, f1);
title(‘f1(t) vs t,(Example 1.7)’);
ylabel(‘f1(t)’)
axis([-6 6 -.5 1.2]);grid on
subplot(2,2,2);
plot(t, f2);
title(‘f2(t) vs t,(Example 1.7)’);
ylabel(‘f2(t)’)
axis([-6 6 -10 200]);grid on
subplot(2,2,3);
plot(t, f3);
title(‘f3(t) vs t,(Example 1.7)’);
ylabel(‘f3(t)’)
axis([-6 6 -.5 1.2]);
grid on;
xlabel(‘t’)
subplot(2,2,4);
plot(t, f4);grid on;
title(‘f4(t) vs t,(Example 1.7)’);
ylabel(‘f4(t)’)
a xis([-6 6 -1.2 .5])
xlabel(‘t’);
Free download pdf