码迷,mamicode.com
首页 > 其他好文 > 详细

《DSP using MATLAB》示例Example 8.29

时间:2017-04-21 09:35:57      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:UI   sig   log   mil   mod   mat   parameter   and   figure   

技术分享

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Exameple 8.29 \n\n‘);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Now is %20s, and it is %8s  \n\n‘, time_stamp, wkd2);
%% ------------------------------------------------------------------------

% Digital Filter Specifications:   Elliptic bandpass
ws = [0.3*pi 0.75*pi];           % digital stopband freq in rad
wp = [0.4*pi 0.6*pi];            % digital passband freq in rad
Rp = 1;                          % passband ripple in dB
As = 40;                         % stopband attenuation in dB

% Calculation of Elliptic filter parameters:
[N, wn] = ellipord(wp/pi, ws/pi, Rp, As);

fprintf(‘\n  ********* Elliptic Filter Order is = %3.0f \n‘, N)

% Digital Elliptic Bandpass Filter Design:
[bhp, ahp] = ellip(N, Rp, As, wn);

[C, B, A] = dir2cas(bhp, ahp)

% Calculation of Frequency Response:
%[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
[dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp);


%% -----------------------------------------------------------------
%%                             Plot
%% -----------------------------------------------------------------  

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Exameple 8.29‘)
set(gcf,‘Color‘,‘white‘); 
M = 1;                          % Omega max

subplot(2,2,1); plot(wwhp/pi, maghp); axis([0, M, 0, 1.2]); grid on;
xlabel(‘ frequency in \pi units‘); ylabel(‘|H|‘); title(‘Magnitude Response‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.3, 0.4, 0.6, 0.75, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [0, 0.8913, 1]);

subplot(2,2,2); plot(wwhp/pi, dbhp); axis([0, M, -50, 2]); grid on;
xlabel(‘ frequency in \pi units‘); ylabel(‘Decibels‘); title(‘Magnitude in dB‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.3, 0.4, 0.6, 0.75, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-50, -40, -1, 0]);

subplot(2,2,3); plot(wwhp/pi, phahp/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel(‘frequency in \pi nuits‘); ylabel(‘radians in \pi units‘); title(‘Phase Response‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.3, 0.4, 0.6, 0.75, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-1:0.5:1]);

subplot(2,2,4); plot(wwhp/pi, grdhp); axis([0, M, 0, 40]); grid on;
xlabel(‘frequency in \pi units‘); ylabel(‘Samples‘); title(‘Group Delay‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.3, 0.4, 0.6, 0.75, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [0:10:40]);

  运行结果:

技术分享

           注意,设计的滤波器是阶数为10。频率响应如下图,

技术分享

 

《DSP using MATLAB》示例Example 8.29

标签:UI   sig   log   mil   mod   mat   parameter   and   figure   

原文地址:http://www.cnblogs.com/ky027wh-sx/p/6741724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!