代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 7.27 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % bandpass
ws1 = 0.25*pi; wp1 = 0.35*pi; wp2=0.65*pi; ws2 = 0.75*pi;
M=40;
delta_w = 2*pi/1000; %% ------------------------------------
%% fir2 Method
%% ------------------------------------
f = [0 ws1 wp1 wp2 ws2 pi]/pi;
m = [0 1 2 2 1 0 ];
h_check = fir2(M-1, f, m, hamming(M)); % if M is odd, then M+1; order
[db, mag, pha, grd, w] = freqz_m(h_check, [1]);
%[Hr,ww,P,L] = ampl_res(h_check);
[Hr, ww, b, L] = Hr_Type2(h_check); fprintf('\n----------------------------------\n');
fprintf('\n fir2 function Method \n');
fprintf('\n----------------------------------\n'); Rp = -(min(db(floor(wp1/delta_w)+1 :1: floor(wp2/delta_w)+1))); % Actual Passband Ripple
fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp);
As = -round(max(db(1:1:floor(0.75*pi/delta_w)+1 ))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n', As); [delta1, delta2] = db2delta(Rp, As) figure('NumberTitle', 'off', 'Name', 'Problem 7.27 fir2 Method')
set(gcf,'Color','white'); subplot(2,1,1); stem([0:M-1], h_check); axis([0 M-1 -0.7 0.9]); grid on;
xlabel('n'); ylabel('h\_check(n)'); title('Actual Impulse Response'); subplot(2,1,2); plot(w/pi, db); axis([0 1 -70 10]); grid on;
set(gca,'YTickMode','manual','YTick',[-60,-21,0])
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'21';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.25,0.35,0.65,0.75,1]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB'); figure('NumberTitle', 'off', 'Name', 'Problem 7.27 h(n) fir2 Method')
set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -70 10]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB');
set(gca,'YTickMode','manual','YTick',[-60,-21,0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'21';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.25,0.35,0.65,0.75,1,1.25,1.35,1.65,1.75,2]); subplot(2,2,3); plot(w/pi, mag); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Absolute'); title('Magnitude Response in absolute');
set(gca,'XTickMode','manual','XTick',[0,0.25,0.35,0.65,0.75,1,1.25,1.35,1.65,1.75,2]);
set(gca,'YTickMode','manual','YTick',[0,1.0,2.0]); subplot(2,2,2); plot(w/pi, pha); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Response in Radians');
subplot(2,2,4); plot(w/pi, grd*pi/180); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Group Delay'); figure('NumberTitle', 'off', 'Name', 'Problem 7.27 AmpRes of h(n),fir2 Method')
set(gcf,'Color','white'); plot(ww/pi, Hr); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Hr'); title('Amplitude Response');
set(gca,'YTickMode','manual','YTick',[0, 1, 1.98,2.02]);
%set(gca,'YTickLabelMode','manual','YTickLabel',['90';'45';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.25,0.35,0.65,0.75,1]);

  运行结果:

《DSP using MATLAB》Problem 7.27的更多相关文章

  1. 《DSP using MATLAB》Problem 5.27

    代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Outp ...

  2. 《DSP using MATLAB》Problem 8.27

    7月底,又一个夏天,又一个火热的夏天,来到火炉城武汉,天天高温橙色预警,到今天已有二十多天. 先看看住的地方 下雨的时候是这样的 接着做题 代码: %% ----------------------- ...

  3. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  4. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.38

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  6. 《DSP using MATLAB》Problem 7.36

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  7. 《DSP using MATLAB》Problem 7.32

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  8. 《DSP using MATLAB》Problem 7.31

    参照Example7.27,因为0.1π=2πf1   f1=0.05,0.9π=2πf2   f2=0.45 所以0.1π≤ω≤0.9π,0.05≤|H|≤0.45 代码: %% +++++++++ ...

  9. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. mfc基于对话框的简单四则运算计算器

    1.①创建mfc对话框窗口,对话框中所有控件都delete. ②绘制界面,按键都button,显示区域edit control,计算器名字用static text. ③所有控件ID改成语义化ID(可不 ...

  2. Java作业:第四次过程性考核 ——长春职业技术学院 16级网络工程

    Java作业:第四次过程性考核 码云链接:https://gitee.com/SoridoD/java_kaohe4    (时间匆忙没打注释,真有急事) (客户端和服务器会自动创建表,所以没有sql ...

  3. MySQL data sync to Oracle with OGG(Remote Delivery)

    MySQL to Oracle with OGG 1. Install MySQL: yum install mysql-community-server [root@localhost ~]#  y ...

  4. centos 远程授权

    centos 远程授权命令 ssh-copy-id root@192.168.15.70

  5. SpringMVC云题库错题及答案汇总-2

    此题目考察的是SpringMVC-注解驱动控制器,注释类型的范围: A.处理requet uri 部分的注解: @PathVariable; B.处理request header部分的注解: @Req ...

  6. firefox 屏蔽Backspace按键的后退功能

    直接上图

  7. Struts2中Action之ResultType

    我们在struts-defalut.xml文件中可以看到如下图所示: 这些类型是配置文件所带的.接下来我们主要讲解我标注出来的这个,其他的我就不做详解了,有兴趣的可以去试试. web.xml文件我在这 ...

  8. json格式字符串用Uncaught SyntaxError: Unexpected token ' Uncaught SyntaxError: Unexpected number

    Unexpected number(index)的错误用的json字符串如 var jsonStr = "{1:'北京note备注信息',2:'上海note备注信息',3:'广东note备注 ...

  9. Python机器学习(基础篇---监督学习(线性分类器))

    监督学习经典模型 机器学习中的监督学习模型的任务重点在于,根据已有的经验知识对未知样本的目标/标记进行预测.根据目标预测变量的类型不同,我们把监督学习任务大体分为分类学习与回归预测两类.监督学习任务的 ...

  10. xss处理

    今天学习了xss,主要记载如下: https://blog.csdn.net/sdauzyh/article/details/74942737