How to design a low pass filter with rectangular window?

45 次查看(过去 30 天)
Hello all, Here, I have a lowpass filter with butter 15Hz cutoff freqeuncy. But I am looking for a low pass filter using rectangular window implimentation.
clear all;
% close all; clc;
%-------------------------------------------------------------
% System definition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------------------------------------------------------------
fs=8192; % sampling frequency
dt = 1/fs; % sample time
T=3; % duration of the signal
Nt = T*fs; % total number of samples
t = 0:dt:T-dt; % time vector
% Source definition
f0 = 900; % initial angular speed in Hz
fT = 2700; % final angular speed in Hz
finst = linspace(f0,fT,Nt);
phi = 2*pi*cumsum(finst)*dt;
a1 = 45;
b1 = 5000;
c1 = 2;
c2 = 1.5;
d1 = 2+3*1j;
% Definition of envelop
int_phi0 = 3*pi/4;
A = d1+(a1 * exp(-b1 * (t - T/c1).^2 + 1j * int_phi0));
% Definition of source signal
q = A.'.*exp(1j*phi).';
filtorder =6; fc =15;%----------------------------------% fc-cutoff
[bcoeff,acoeff] = butter(filtorder,fc/fs*2);
Afilt = filtfilt(bcoeff,acoeff,q.*exp(-1j*phi).');
figure()
plot(t,q,'k')
Warning: Imaginary parts of complex X and/or Y arguments ignored.
hold on
plot(t,abs(Afilt),'r','LineWidth',2)
grid on; box on;
legend('q(t)','A(t)')
xlabel('s')
ylabel('Amp')
title('q(t) and A(t) - filtered')
set(gca,'FontSize',15)
xlim([1.2 1.8])

回答(1 个)

N A POORNA CHANDRA
hi kalasagarreddi, here is the code for low pass filter with rectangular window
clear all;
clc;
fs = 8192; % Sampling frequency
dt = 1/fs; % Sample time
T = 3; % Duration of the signal
Nt = T*fs; % Total number of samples
t = 0:dt:T-dt; % Time vector
f0 = 900; % Initial angular speed in Hz
fT = 2700; % Final angular speed in Hz
finst = linspace(f0,fT,Nt);
phi = 2*pi*cumsum(finst)*dt;
a1 = 45;
b1 = 5000;
c1 = 2;
c2 = 1.5;
d1 = 2+3*1j;
%envelop
int_phi0 = 3*pi/4;
A = d1 + (a1 * exp(-b1 * (t - T/c1).^2 + 1j * int_phi0));
% source signal
q = A.'.*exp(1j*phi).';
% Low-pass filter using Kaiser window
fc = 15; % Cutoff frequency in Hz
normalized_fc = fc / (fs/2); % Normalized cutoff frequency
filter_order = 50; % Filter order
beta = kaiser(filter_order+1, 8); % Kaiser window with beta = 8
h = fir1(filter_order, normalized_fc, 'low', beta); % Filter coefficients
Afilt = filtfilt(h, 1, q.*exp(-1j*phi).');
figure();
plot(t, q, 'k');
hold on;
plot(t, abs(Afilt), 'r', 'LineWidth', 2);
grid on;
box on;
legend('q(t)', 'A(t)');
xlabel('s');
ylabel('Amp');
title('q(t) and A(t) - filtered');
set(gca,'FontSize',15);
xlim([1.2 1.8]);
  1 个评论
Kalasagarreddi Kottakota
Hi @N A POORNA CHANDRA, I think there is a issue with this type of filtering. The result it produces is not even near to the result, I have shown in my question.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Filter Design 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by