%%%%%%%%%%%%%%%%%%%%%%%%%%%% % File Name: PlotFilter.m % Jiwon Seo (jwseo@stanford.edu, jiwons@gmail.com) % 2/24/2008 function PlotFilter(filterCoeff, H_design, W_design) close all; % Close all existing figures. stem(filterCoeff); xlabel('Sample Number (n)'); ylabel('h(n)'); % If you want to include some "variables" in the title % or labels, you could use the following trick. % ('...' just connects two lines.) title(['Filter Coefficients (Length = ' ... int2str(length(filterCoeff)) ')']); % Make another figure and hold the figure % to plot multiple graphs on top of each other. figure; hold on; % 'subplot' is also a good thing to know. subplot(2,1,1); plot(W_design / pi, abs(H_design)); % In order to include ' in a string, you should % type it twice! title('Filter''s Magnitude Response'); ylabel('Magnitude (absolute value)'); subplot(2,1,2); plot(W_design / pi, AbsTo_dB(abs(H_design))); % You can print Greek letter on the screen. % (eg. \pi) xlabel('Normalized Frequency (x \pi rad/sample)'); ylabel('Magnitude (dB)');