![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935684/image.png)
Spatial filtering from FFT results
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/923869/image.png)
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)|')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/923874/image.png)
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/923879/image.png)
Any advice?
0 commentaires
Réponses (1)
Mathieu NOE
le 21 Mar 2022
hello
my suggestion below
look at the yellow trace
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/935684/image.png)
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');
0 commentaires
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!