PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 369


************RESULTS*************
F(s) is given by:

3 s + 25
------------
s^2 + 3 s + 2

The ILT of F(s) is given by:

-19 exp(-2 t) + 22 exp(-t)
**********************************

R.4.122 A plot that relates to the amplitude of a given function f(t), its frequency w, and
its time t, is called a spectrogram. In its simplest version, the MATLAB function
specgram(f) returns the plots of the spectrogram of the function f(t) specifi ed by the
row vector f, with a default sampling frequency of Fs = 1 /Ts = 2.
R.4.123 In its simplest version, the MATLAB function psd(f) returns the power spectrum
density of the function f(t) defi ned by the vector f.
R.4.124 Recall that MATLAB provides with a speech fi le named mtlb.mat that consists of
4001 samples, sampled at 1418 Hz. Recall also that this fi le (mtlb.mat) is often used
for testing purposes (Chapter 1).
R.4.125 The following example illustrates how the MATLAB functions specgram and psd
can be used on an arbitrary fi le (voice, audio, video, or data), or on a data array.
For example, create the script fi le specpsd that returns the following plots (Fig-
ures 4.20 and 4.21):



  1. The speech fi le mtlb.mat versus t




  2. y(t) = 3 cos(2πt/2000), sampled with a rate of T = 1 , for t = 0, 1, 2, 3, 4,..., 4000
    (returning 4001 samples) versus t




  3. A random noisy signal defi ned by noise = (^2) * rand(1 : 4001) versus t




  4. ynoise = y(t) + noise, over the fi rst 1000 samples.




  5. The spectrogram of the fi le mtlb




  6. psd of the fi le mtlb




  7. The spectrogram of the sequence ynoise




  8. psd of the sequence ynoise




MATLAB Solution
% Script file: specpsd
% load speech file mtlb
load mtlb;
x = 1:4001; % time sequence
figure(1)
subplot(2,2,1);
plot(x,mtlb);
axis([0 4000 -4 4]);
ylabel(‘Amplitude ‘);
title(‘[Speech file mtlb] vs. t’)
noise= rand(1,4001)*2; % noise sequence;
y = 3*cos(2*pi*x/2000);
Free download pdf