52 Practical MATLAB® Applications for Engineers
wtri = triang(31);
wrect = boxcar(31);
wbart = bartlett(31);
plot (n,wtri,’*’,n,wrect,’d’,n,wbart,’o’);
hold
plot (n,wtri,n,wrect,n,wbart);
title (‘TRIANGULAR,RECTANGULAR and BARTLETT windows ‘);
xlabel (‘points n’);
ylabel (‘Amplitude’)
legend (‘TRIAN’,’RECT’,’BART’);
axis([-18 18 0 1.3]);
R.1.160 For completeness, a random or noise-like signal is presented below.
The MATLAB statement sqrt(P)*randn(1, n) returns a white Gaussian noise
sequence with power P.
R.1.161 For example, create the script fi le signal_noise that returns the plots of the follow-
ing signals:
a. Gaussian white noise
b. The signal—signal = cos(2πn/64)
c. The contaminated signal plus noise using n = 128 elements. Let the white
Gaussian signal power be P = 2.7 watts
TRIANGULAR, RECTANGULAR, and BARTLETT windows
1.2
1
0.8
0.6
0.4
0.2
0
− 15 − 10 − 5 0 5 10 15
Amplitude
TRIAN
RECT
BART
(31-point approximations)
points n
FIGURE 1.42
Plots of the triangular, rectangular, and Bartlett window of R.1.159.