Spatial filtering from FFT results

6 次查看(过去 30 天)
Wookie
Wookie 2022-3-11
I have a spatial signal that has frequencies that I'd like to filter out, the signal is seen below. I need some advice in removing those valleys and leaving just the top portion. I still need the large valley seen around 700.
My code to filter it has been:
dx=0.2; %mm
Fs=1/dx; %1/mm
L = length(metrology_s1); % Length of signal
t = (0:L-1)*Fs;
Y = fft(metrology_s1);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
From here I am not applying filters correctly:
% Second attempt
wo = 0.012207/(.2); %
bw = wo/.5;
[b,a] = iirnotch(wo,bw);
fil = filtfilt(b,a,metrology_s1);
Any advice?

回答(1 个)

Mathieu NOE
Mathieu NOE 2022-3-21
hello
my suggestion below
look at the yellow trace
y = readmatrix('metrology_s1.csv');
samples = numel(y);
% create x vector
dx = 0.2;
Fs = 1/dx;
x = (0:samples-1)*dx;
% smooth data
ys = smoothdata(y,'rloess',300);
% add min (max negative) point
[y_min,ind] = min(y);
x_min = x(ind);
%create an exponential window centered on the negative peak and use that to
%"blend" the smoothed data with the raw data
blend_ratio = exp(-(x-x_min).^4/1000);
% plot(x,blend_ratio); % debug / test only
y_blended = ys.*(1-blend_ratio)+ y.*(blend_ratio);
plot(x,y,x,ys,x,y_blended)
legend('raw','smoothed','blended');

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by