《DSP using MATLAB》Problem 8.13

代码:

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

banner();
%% ------------------------------------------------------------------------

Wp = 20*pi; Ws = 40*pi; Rp = 0.5; As = 45;
Fp = Wp/(2*pi);
Fs = Ws/(2*pi);

Ripple = 10 ^ (-Rp/20)
Attn = 10 ^ (-As/20)

% Analog filter design:
[b, a] = afd(‘butter‘, Fp, Fs, Rp, As);
%[b, a] = afd_butt(Wp, Ws, Rp, As);

% Calculation of second-order sections:
[C, B, A] = sdir2cas(b, a);

% Calculation of Frequency Response:
[db, mag, pha, ww] = freqs_m(b, a, 45*pi);

% Calculation of Impulse Response:
[ha, x, t] = impulse(b, a);

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

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 8.13 Analog Butterworth lowpass‘)
set(gcf,‘Color‘,‘white‘);
M = 1.0;                          % Omega max

subplot(2,2,1); plot(ww/pi, mag);  grid on; axis([-45, 45, 0, 1.2]);
xlabel(‘ Analog frequency in \pi*1k units‘); ylabel(‘|H|‘); title(‘Magnitude in Absolute‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [-45, -40, -20, 0, 20, 40, 45]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [0, 0.005, 0.94, 1]);

subplot(2,2,2); plot(ww/pi, db);  grid on; %axis([0, M, -50, 10]);
xlabel(‘Analog frequency in \pi*1k units‘); ylabel(‘Decibels‘); title(‘Magnitude in dB ‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [-45, -40, -20, 0, 20, 40, 45]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-50, -45, -10, 0]);
set(gca,‘YTickLabelMode‘,‘manual‘,‘YTickLabel‘,[‘50‘;‘45‘;‘10‘;‘ 0‘]);

subplot(2,2,3); plot(ww/pi, pha/pi);  grid on; axis([-45, 45, -1.2, 1.2]);
xlabel(‘Analog frequency in \pi*1k nuits‘); ylabel(‘radians‘); title(‘Phase Response‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [-45, -40, -20, 0, 20, 40, 45]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-1:0.5:1]);

subplot(2,2,4); plot(t, ha); grid on; %axis([0, 30, -0.05, 0.25]);
xlabel(‘time in seconds‘); ylabel(‘ha(t)‘); title(‘Impulse Response‘);

  运行结果:

通带、阻带绝对指标

模拟butterworth低通,直接形式系数

串联形式系数

幅度谱、相位谱和脉冲响应。

原文地址:https://www.cnblogs.com/ky027wh-sx/p/11019761.html

时间: 2024-11-09 01:48:10

《DSP using MATLAB》Problem 8.13的相关文章

《DSP using MATLAB》Problem 4.13

代码: %% ---------------------------------------------------------------------------- %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 4.13 \n\n'); banner

《DSP using MATLAB》Problem 5.13

1. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.13 \n\n');

《DSP using MATLAB》Problem 3.1

先写DTFT子函数: function [X] = dtft(x, n, w) %% ------------------------------------------------------------------------ %% Computes DTFT (Discrete-Time Fourier Transform) %% of Finite-Duration Sequence %% Note: NOT the most elegant way % [X] = dtft(x, n,

《DSP using MATLAB》Problem 4.11

代码: %% ---------------------------------------------------------------------------- %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 4.11 \n\n'); banner

《DSP using MATLAB》Problem 6.12

代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 6.12 \n\n'); ba

《DSP using MATLAB》Problem 7.28

又是一年五一节,朋友圈都是晒名山大川的,晒脑袋的,我这没钱的待在家里上网转转吧 频率采样法设计带通滤波器,过渡带中有一个样点 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n*******************************************************

《DSP using MATLAB》Problem 9.4

只放第1小题. 代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 9.4.1 \n\n'); b

《DSP using MATLAB》 Problem 2.3

本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.3.1 \

《DSP using MATLAB》Problem 2.5

2.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.5.2 \n\n'); time_st