Time Domain Representation of Continuous and Discrete Signals
53
MATLAB Solution
% Script file: signal _ noise
n = 1:128; P =2.7;
figure(1)
subplot(2,1,1)
white _ noise = sqrt(P)*randn(1,128);
stem(n,white _ noise); hold on;plot(n,white _ noise);
xlabel(‘discrete time n’);
ylabel(‘Amplitude’); title(‘Gaussian noise’);
subplot(2,1,2)
signal = cos(2*pi*n/64);
stem(n,signal);hold on;plot(n,signal);
title(‘cosine wave with period=64’)
xlabel(‘discrete time n’);
ylabel(‘Amplitude’);
figure(2)
signal _ noise = white _ noise+signal;
stem(n,signal _ noise);hold on;plot(n,signal _ noise);
title(‘cosine wave plus white Gaussian noise’)
xlabel(‘discrete time n’);
ylabel(‘Amplitude’);
The script fi le signal_noise is executed as follows and the results are shown in
Figures 1.43 and 1.44.
FIGURE 1.43
Plots of parts a and b of R.1.161.
Gaussian noise
4
2
0
−2
−4
0
40
60
80
100
120
140
20
Amplitude
Amplitude
discrete time n
cosine wave with period = 64
1
0.5
0
−0.5
−1
0
20
40
60
80
100
120
140
discrete time n
CRC_47760_CH001.indd 53
CRC_47760_CH001.indd 53
7/25/2008 4:16:20 PM
7/25/2008 4:16:20 PM
53
MATLAB Solution
% Script file: signal _ noise
n = 1:128; P =2.7;
figure(1)
subplot(2,1,1)
white _ noise = sqrt(P)*randn(1,128);
stem(n,white _ noise); hold on;plot(n,white _ noise);
xlabel(‘discrete time n’);
ylabel(‘Amplitude’); title(‘Gaussian noise’);
subplot(2,1,2)
signal = cos(2*pi*n/64);
stem(n,signal);hold on;plot(n,signal);
title(‘cosine wave with period=64’)
xlabel(‘discrete time n’);
ylabel(‘Amplitude’);
figure(2)
signal _ noise = white _ noise+signal;
stem(n,signal _ noise);hold on;plot(n,signal _ noise);
title(‘cosine wave plus white Gaussian noise’)
xlabel(‘discrete time n’);
ylabel(‘Amplitude’);
The script fi le signal_noise is executed as follows and the results are shown in
Figures 1.43 and 1.44.
FIGURE 1.43
Plots of parts a and b of R.1.161.
Gaussian noise
4
2
0
−2
−4
0
40
60
80
100
120
140
20
Amplitude
Amplitude
discrete time n
cosine wave with period = 64
1
0.5
0
−0.5
−1
0
20
40
60
80
100
120
140
discrete time n
CRC_47760_CH001.indd 53
CRC_47760_CH001.indd 53
7/25/2008 4:16:20 PM
7/25/2008 4:16:20 PM
