How to remove sidelobes using fdatool
Afficher commentaires plus anciens
I have generated an 802.11a frame using my VHDL simulation. When I analyze it in the frequency domain(cap data through iio oscilloscope), I observe sidelobes. I attempted to address this by adjusting parameters in the RF configuration, but to no avail. Now, I'm trying to remove these sidelobes using MATLAB's 'fdatool'. As I'm new to this tool, I designed a basic filter and saved its coefficients, but the resulting spectrum still appears distorted. Could you guide me on where I might be going wrong, and how I can correct this?
sampling fq=20Mhz
Filter Design



Atteched my files
matlab code :
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
load('num_coef100.mat'); % fdatool genarated coefficients
LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
filter_coefficients = LPF;
% Apply the filter to your IQ data
filtered_data = filter(filter_coefficients, 1, iq_data); % FIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');
Réponses (1)
hello
i prefer to use an elliptic filter as it has a steep roll off after the cut of frequency (fc)
here's the filter alone
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 6; % 6th-order lowpass elliptic filter
ripple_dB = 3; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
freqz(b,a,[],fs)
subplot(2,1,1)
ylim([-100 20])

and used in your code
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
% load('num_coef100.mat'); % fdatool genarated coefficients
% LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
% filter_coefficients = LPF;
% Apply the filter to your IQ data
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 6; % 6th-order lowpass elliptic filter
ripple_dB = 3; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
filtered_data = filter(b, a, iq_data); % IIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');
9 commentaires
VIJETH J SHETTY
le 29 Fév 2024
Mathieu NOE
le 29 Fév 2024
hello again
maybe we have to double fc
can you try again with fc = 0.5
Mathieu NOE
le 29 Fév 2024
Modifié(e) : Mathieu NOE
le 29 Fév 2024
also, maybe this is not relevant, but I wonder if we would rather use filtfilt instead of filter
filtfilt does twice the filter action, once in forward time and a second time in backward time direction, so the filter's phase delay is compensated
this is the real portion of your signal before and after filtering with filter with the 6th order elliptic filter
notice the time shift

now with filtfilt, (and to have the same amount of filtering I reduced the order to 3 , but it's applied twice on the signal so it's basically the same as doing one filtering with a 6th order filter)
notice NO time shift

code :
clc;
clear;
close;
data=readmatrix("DATA1.csv"); % VHDL genarated data IQ
% load('num_coef100.mat'); % fdatool genarated coefficients
% LPF=(coef_100.');
real1=data(:,1);
imag1=data(:,2);
IQ_DATA= real1 + 1i*imag1 ;
iq_data = IQ_DATA;
% filter_coefficients = LPF;
% Apply the filter to your IQ data
fc = 0.25; % cut off freq (normalized to fs/2)
fs = 1;
order = 3; % 6th-order lowpass elliptic filter
ripple_dB = 1; %passband ripple
sa = 30; % stopband attenuation,
[b,a] = ellip(order,ripple_dB,sa,fc/(fs/2));
% filtered_data = filter(b, a, iq_data); % IIR
filtered_data = filtfilt(b, a, iq_data); % IIR
% Compute the FFT of the original IQ data
N = length(iq_data);
fft_original = fftshift(fft(iq_data));
fft_freq_original = (-N/2:N/2-1)*(1/N);
% Compute the FFT of the filtered data
fft_filtered = fftshift(fft(filtered_data));
fft_freq_filtered = (-N/2:N/2-1)*(1/N);
figure;
subplot(2,1,1);
plot(fft_freq_original, abs(fft_original), 'b');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum Before Applying Filter');
subplot(2,1,2);
plot(fft_freq_filtered, abs(fft_filtered), 'r');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Frequency Spectrum After Applying Filter');
VIJETH J SHETTY
le 4 Mar 2024
Modifié(e) : VIJETH J SHETTY
le 4 Mar 2024
Mathieu NOE
le 4 Mar 2024
then maybe yhe idea of filtering the data is simply not the good path
is there any reason why the sidelobes appear in first instance ?
VIJETH J SHETTY
le 5 Mar 2024
Mathieu NOE
le 5 Mar 2024
ok , tx for the infos
unfortunately I cannot really help on the Tx / Rx potential issues due to hardware
VIJETH J SHETTY
le 6 Mar 2024
Mathieu NOE
le 6 Mar 2024
Wished I ould do better, but I am aware that I have reached my limits
hope you find a way to solve it
Catégories
En savoir plus sur Code Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


