Please help me solve this question. Thanks. 3.2 Overlay Plotting Sometimes it is
ID: 2250089 • Letter: P
Question
Please help me solve this question. Thanks.
3.2 Overlay Plotting
Sometimes it is convenient to overlay information onto an existing MATLAB plot. The MATLAB command hold on will inhibit the figure erase that is usually done just before a new plot. Demonstrate that you can do an overlay by following these instructions:
(a) Plot the magnitude response of the 5-point averager, created from HH=freqz(ones(1,5)/5,1,ww). Make sure that the horizontal frequency axis extends from to + by defining the appropriate set of frequency samples in ww.
(b) Use the stem function to place vertical markers at the zeros of the frequency response. >> hold on, stem(2*pi/5*[-2,-1,1,2],0.3*ones(1,4),’r.’), hold off
Explanation / Answer
Overlay Plotting is nothing but plotting multiple figures in the same figure. It is usually done in graphs.
Comming to the commands or steps mentioned in the question
(a) HH=freqz(ones(1,5)/5,1,ww)
freqz in MATLAB is used to find out the frequency response of a digital filter, it returns a frequency response of n-point and the corresponding angular frequency hence we here get a graph plotted.
(b) >> hold on, stem(2*pi/5*[-2,-1,1,2],0.3*ones(1,4),’r.’), hold off
hold on and hold off play an important role in achieving multiple plots that overlay plotting . HOLD ON holds the previous plot, STEM plots the data sequences of the inner function which forms another graph and HOLD OFF releases the previous graph .
Hence this is how overlay plotting is achieved.