MATLAB Signal Processing: Digital and Analog Filter Design
Classified in Mathematics
Written on in
with a size of 2.29 KB
Digital Signal Processing
Load the data file: load('exam.mat');
Parameters
x = xBPFI;% Input signalFs = 10e3;% Sampling frequencyTs = 1/Fs;t = (0:length(x)-1) * Ts;% Time vectorn_f = 10000;f = (0:n_f-1)*Fs/n_f;% Frequency vector
Input Signal Analysis
Plotting the input signal in the time and frequency domains:
plot(t,x); xlabel('t (s)'); ylabel('x(t) (V)'); title('Input signal in TIME');
X = fft(x,n_f)/length(x);
figure(); subplot(2,1,1); plot(f,abs(X)); xlabel('f (Hz)'); ylabel('|X(f)| (V)'); title('Input signal in FREQUENCY');
subplot(2,1,2); plot(f,angle(X)); xlabel('f (Hz)'); ylabel('\angleX(f) (rad)');Bandpass Filter Design
Configuring the filter parameters and applying a Hamming window:
Tbw = 150; fpl = 2400; fcl = (fpl-Tbw/2)/Fs; wcl = 2*pi*fcl;fph = 3600; fch = (fph+Tbw/2)/Fs; wch = 2*pi*fch;
K_hamming = 3.3*Fs/Tbw; K_hamming = K_hamming + 1 - mod(K_hamming,2);
k_center_hamming = (K_hamming-1)/2+1;
k_hamming = (-(K_hamming-1)/2:(K_hamming-1)/2);
W_hamming = 0.54 + 0.46*cos(2*pi*k_hamming/(K_hamming));
hd_bp = 2*fch*sinc(2*k_hamming*fch) - 2*fcl*sinc(2*k_hamming*fcl);
hd_bp(k_center_hamming) = 2*fch-2*fcl;
h_bp = hd_bp .* W_hamming;Output Filtered Signal
Applying the filter via convolution and analyzing the results:
y_bp = conv(h_bp,x);
t_ybp = (0:(length(y_bp)-1))*Ts;
figure(); plot(t_ybp,y_bp); title('Bearing fault output signal in TIME');
Y_bp = fft(y_bp,n_f)/length(y_bp);Analog Filter Analysis
close all; clear; clc;
Transfer Function Representation
Representing the magnitude and phase of the transfer function H(f):
F_step = 10000; nfft = 100000; dfx = F_step/nfft;
f = (- F_step/2:dfx:F_step/2-1); w = 2*pi*f; s = 1i*w;
R = 330; L = 1e-2; C = 1e-6;
H = 1./(s.^2*L*C + s*R*C + 1);
bode(1,[L*C R*C 1]);Calculating the cutoff frequency for the low-pass filter:
cutting_freq1 = sqrt(-R^2*C^2+2*L*C+sqrt((R^2*C^2- 2*L*C)^2+4*L^2*C^2))/ sqrt((2*L^2*C^2))/2/pi;