📄 cp6_1.m
字号:
%%%%%%%%%%% Comprehensive Problem 6.1 %%%%%%%%%%%
% Discrete-Time Control Problems using %
% MATLAB and the Control System Toolbox %
% by J.H. Chow, D.K. Frederick, & N.W. Chbat %
% Brooks/Cole Publishing Company %
% September 2002 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- Drum beat sound track ----
%
% drum sound track recorded by Nick Chbat
% m file by Joe Chow
load local
fs = 16384 % sampling rate
%
% extract the main part of the signal
% use 65536 point
N = 2^16;
%
kstart = 10000;
y = local(kstart:kstart+N-1);
t=[0:length(y)-1]'/fs;
figure, plot(t,y),grid
xlabel('Time (sec)')
ylabel('local')
title('Original drum beats')
sound(y,fs)
disp('Playing original drum beat sound track')
disp('*******>'), pause
disp('Frequency response of original signal')
yfft = fft(y);
% frequency scale
df = fs/N;
f = [0:df:fs-df];
figure, plot(f,abs(yfft)),grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
title('Magnitude of frequency response of original signal')
disp('*******>'), pause
% 1st order butterworth filter
H1 = tf([0.5792 0.5792],[1 0.1584],1/fs);
H1 = ss(H1);
H = H1*H1;
yf = lsim(H,y,t);
figure, plot(t,yf),grid
xlabel('Time (sec)')
ylabel('local')
title('Low-pass filtered drum beats')
sound(yf,fs)
disp('Playing filtered drum beat sound track')
disp('*******>'), pause
disp('Frequency response of filtered signal')
yffft = fft(yf);
% frequency scale
df = fs/N;
f = [0:df:fs-df];
figure, plot(f,abs(yffft)),grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
title('Magnitude of frequency response of the filtered signal')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -