⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reinf6_9.m

📁 离散控制系统设计的MATLAB 代码
💻 M
字号:
%%%%%%%%%%% Reinforcement Problem 6.9 %%%%%%%%%%%
%   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                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ---- Response of the series connection of a -----
%   ----  highpass and bandstop digital filter  ----
%
clear
disp('Reinforcement Problem 6.9')

Ts = 0.01;                           % sampling period
%---------- highpass filter from Problem 6.7 ----
Ghp = tf(3.077*[1 -0.5],[1 0.5385],Ts)  

%-------- bandstop filter from Problem 6.8 ----
w0 = 50*pi;
a = 0.95, b = 0.5, K = 7.692
num = K*conv([1 -a*exp(j*w0*Ts)],[1 -a*exp(-j*w0*Ts)]);
den = conv([1 -b*exp(j*w0*Ts)],[1 -b*exp(-j*w0*Ts)]);
Gbs = tf(num,den,Ts)		

%----- series connection --------
G = Ghp*Gbs

w = logspace(-2,0,50)*pi/Ts;          % specify frequency range

figure
bode(G,w)                             % frequency response plot

t = [0:Ts:10.0-Ts];                   % time array from 0 to 9.99 sec
e = cos(14*pi*t)+cos(50*pi*t)+cos(86*pi*t);  % DT signal
y = lsim(G,e);                        % filter output
t9 = [901:1000]';

figure
title('Input and output signals for Reinforcement Problem 6.9')
subplot(2,1,1)                        % split graphics window
stem(t(t9),e(t9),':','filled'), grid
legend('Input signal')
axis([9.5 10.0 -4 4])				  % show only last 0.5 s
xlabel('Time (s)')
subplot(2,1,2)
stem(t(t9),y(t9),':o'), grid
axis([9.5 10.0 -120 120])		   	  % show only last 0.5 s
legend('Output signal')
xlabel('Time (s)')

N = length(y(t9));                % number of data points
Yp = fft(y(t9))/N;                % Compute Fourier Series Coeffs
ff = [0:1/Ts/N:(1.0-Ts)/Ts];      % frequency array

figure
stem(ff,abs(Yp));grid                 % magnitude plot
ylabel('magnitude')
xlabel('frequency (Hz)')
title('Magnitudes of output Fourier-series coeffs for Reinf. Prob. 6.9')
%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -