zoukankan      html  css  js  c++  java
  • 《DSP using MATLAB》示例Example 6.27

    代码:

    % 
    r = 0.9; theta = (pi/180)*[-55:5:-35, 35:5:55]';
    p = r*exp(j*theta); a = poly(p); b = 1;
    w = [0:500]*pi/500; H = freqz(b*1e-4, a, w);
    magH = abs(H); magHdb = 20*log10(magH);
    
    % Direct form: quantized coefficients
    N = 15; [ahat, L, B] = QCoeff(a, N);
    TITLE = sprintf('%i-bit (1+%i+%i) Precision (DF)', N+1, L, B);
    Hhat = freqz(b*1e-4, ahat, w); magHhat = abs(Hhat);
    
    % Cascade form: quantized coefficients: Same N
    [b0, B0, A0] = dir2cas(b, a); [BAhat1, L1, B1] = QCoeff([B0, A0], N);
    TITLE1 = sprintf('%i-bit (1+%i+%i) Precision (CF)', N+1, L1, B1);
    Bhat1 = BAhat1(:, 1:3); Ahat1 = BAhat1(:, 4:6);
    [bhat1, ahat1] = cas2dir(b0, Bhat1, Ahat1);
    Hhat1 = freqz(b*1e-4, ahat1, w); magHhat1 = abs(Hhat1);
    
    % Cascade fomr: quantized coefficients: Same B (N=L1+B)
    N1 = L1 + B; [BAhat2, L2, B2] = QCoeff([B0, A0], N1);
    TITLE2 = sprintf('%i-bit (1+%i+%i) Precision (CF)', N1+1, L2, B2);
    Bhat2 = BAhat2(:, 1:3); Ahat2 = BAhat2(:, 4:6);
    [bhat2, ahat2] = cas2dir(b0, Bhat2, Ahat2);
    Hhat2 = freqz(b*1e-4, ahat2, w); magHhat2 = abs(Hhat2);
    
    
    % Comparison of Magnitude Plots
    Hf_1 = figure('paperunits', 'inches', 'paperposition', [0, 0, 6, 4]);
    %figure('NumberTitle', 'off', 'Name', 'Exameple 6.26a')
    set(gcf,'Color','white');
    
    subplot(2, 2, 1); plot(w/pi, magH, 'g', 'linewidth', 2); axis([0, 1, 0, 0.7]);
    xlabel('Digital Frequency in pi units', 'fontsize', 10);
    ylabel('Magnitude Response', 'fontsize', 10); grid on;
    title('Infinite Precision (DF)', 'fontsize', 10, 'fontweight', 'bold');
    
    subplot(2, 2, 2); plot(w/pi, magHhat, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
    xlabel('Digital Frequency in pi units', 'fontsize', 10);
    ylabel('Magnitude Response', 'fontsize', 10); grid on;
    title(TITLE, 'fontsize', 10, 'fontweight', 'bold');
    
    subplot(2, 2, 3); plot(w/pi, magHhat1, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
    xlabel('Digital Frequency in pi units', 'fontsize', 10);
    ylabel('Magnitude Response', 'fontsize', 10); grid on;
    title(TITLE1, 'fontsize', 10, 'fontweight', 'bold');
    
    subplot(2, 2, 4); plot(w/pi, magHhat2, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
    xlabel('Digital Frequency in pi units', 'fontsize', 10);
    ylabel('Magnitude Response', 'fontsize', 10); grid on;
    title(TITLE2, 'fontsize', 10, 'fontweight', 'bold');
    

     运行结果:

    牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
  • 相关阅读:
    Java Web之Tomcat
    Java Web之HTML5
    Java 读取propertoes文件
    SQL Server 触发器
    通过关闭 UseDNS和GSSAPIAuthentication选项加速 SSH登录
    数据库创建索引有什么优点和缺点
    修改查看MYSQL字符集(charset)
    MySQL 数据类型
    远程连接mysql数据库提示:ERROR 1130的解决办法
    怎么快速了解自己的MySQL服务器?
  • 原文地址:https://www.cnblogs.com/ky027wh-sx/p/6606691.html
Copyright © 2011-2022 走看看