PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

54 Practical MATLAB® Applications for Engineers


R.1.162 Sound waves can be represented by 1-D vectors while 2-D matrices can be used
to represent images (black and white), whereas higher dimension matrices can be
used to represent color images and video.


R.1.163 The MATLAB command wavrecord(N, Fs) takes the N audio elements sampled at
a frequency of Fs, directly from an audio input device such as a microphone. The
default value for Fs is 11,025 Hz. This function can only be used with Windows 95,
98, or NT machines.


R.1.164 The MATLAB command wavplay(y, Fs) sends the audio signal defi ned by the vector
y, sampled at a frequency of Fs Hertz to an output audio device. Standard audio rates
are 8000 , 11,025, 22,050, and 44,100 Hz. The MATLAB default rate is 11,025 Hz.


R.1.165 MATLAB provides with a sound fi le called sound(y, Fs), and soundsc(y, Fs), that
sends the audio signal defi ned by y to an out put audio device. y is assumed to have
a magnitude range −1.0 ≤ y ≤ 1.0, and any values outside that range is clipped.
The difference between sound and soundsc is that the latter is autoscale, and y is
played as loud as possible. The MATLAB default sound rate is 8192 Hz.
MATLAB also provides with a speech fi le named mtlb.mat that can be used for
testing purposes, consists of 4001 elements, sampled at 1418 Hz.


R.1.166 The following example shows the script fi le audio that returns


a. The plot of the sinusoidal audio signal is given by y = cos(2πfot) + 3 cos(0.5πfot);
where fo = 1000 Hz, and a sample frequency of Fs = 8000 Hz (implying that
8000 audio samples per second are processed).
b. The speech fi le mtlb (Figure 1.45).

cosine wave plus white Gaussian noise
5 4 3 2 1 0

− 1

− 2

− 3

− 4

− 5
0 20 40 60 80 100 120 140
discrete time n

Amplitude

FIGURE 1.44
Plot of part c of R.1.161.

Free download pdf