PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

DTFT, DFT, ZT, and FFT 555


>> step _ imp
****************************************************************
*********************** R E S U L T S *************************
****************************************************************
The first 11 coefficients of the step response
using the simulation of the difference equation are :
a =
2.0000 3.0000 3.5000 3.7500 3.8750 3.9375 3.9688
3.9844 3.9922 3.9961 3.9980
using the command dstep are :
b =
2.0000 3.0000 3.5000 3.7500 3.8750 3.9375 3.9688
3.9844 3.9922 3.9961 3.9980
The first 11 coefficients of the impulse response
using the simulation of the difference equation are :
c =
2.0000 1.0000 0.5000 0.2500 0.1250 0.0625 0.0313
0.0156 0.0078 0.0039 0.0020
using the command impz are:
d =
2.0000 1.0000 0.5000 0.2500 0.1250 0.0625 0.0313
0.0156 0.0078 0.0039 0.0020
The cumulative step error [a-b] is :
ans =
0
The cumulative impulse error [c-d] is :
ans =
0
****************************************************************

Example 5.19

The objective of this example is to illustrate the computational effi ciency of evaluating
the fft when the sequence length is a power of 2.
Create the script fi les time_analysis_ 512 and time_analysis_ 513, that returns the time
statistics by evaluating the fft of the signal f(t) = cos(2π850t), twice using 512 and 513
samples, respectively, with a sampling rate of Ts = 1/8000 in both.

MATLAB Solution
% Script file: time _ analysis _ 512
% statistic analysis using 512 points; a power of 2
clear;
tstart = clock; tic;
ta = cputime;
fs = 8000;Ts=1/fs;N=512;
t = linspace(0,Ts*511,512);signal _ 512 = cos(2*pi*850.*t);
DFT _ 512 = fft(signal _ 512,512);
estimea = etime(clock,tstart);
tictoca = toc;
t1= cputime-ta;
disp(‘********************* R E S U L T S **********************’)
disp(‘********** T I M E S T A T I S T I C S **********’)
disp(‘ f(n) consist of 512 samples ‘)
fprintf(‘est.time = %6.6f\n’,estimea);
Free download pdf