What is the frequency of my signal?
3 次查看(过去 30 天)
显示 更早的评论
Hey everybody,
i have measurement data that i want to filter using a lowpass, bandpass, etc.
To filter it i first wanted to get the frequency of the signal so that i can design my filter properly. Unfortunately there is no peak at a certain frequency as i am used to with other sensors so i am not sure how to filter it. Also i am really surprised by the small frequencys of 0.0X Hz. Is there maybe a mistake in my code? How would you filter this signal?
I also attached the measurement data.
Thank you very much.
%% Fourier-Transformation
CH0 = detrend(CH0);
L = numel(CH0);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
CH0FT = fft(CH0-mean(CH0),[],1)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
CH0abs = abs(CH0FT);
plot(Fv,mag2db(CH0abs(Iv)*2));
0 个评论
采纳的回答
Star Strider
2021-7-26
编辑:Star Strider
2021-7-26
Try this —
LD = load('Frequency.mat');
t = LD.t;
CH0 = LD.CH0;
Fs = 0.1; % Design Sampling Frequency
[CH0r,tr] = resample(CH0,t,Fs); % Resample To Constant Sampling Intervals
L = numel(t); % Original Signal Length
Fn = Fs/2; % Myquist Frequency
N = 2^nextpow2(L); % Fourier Transform Length
CH0rm = CH0r - mean(CH0r); % Subtract Mean So Peaks Are More Easily Visible
FT_CH0r = fft(CH0rm,N)/L; % Fourier Transform
Fv = linspace(0, 1, N/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FT_CH0r(Iv))*2, '-')
grid
xlim([0 0.02])
xlabel('Frequency')
ylabel('Amplitude')
[CH0rmax,idx] = max(abs(FT_CH0r(Iv))*2);
text(Fv(idx), CH0rmax, sprintf('$\\leftarrow Amplitude: %6.1f$\n$\\ \\ \\ \\ Frequency = %.6f$',CH0rmax,Fv(idx)), 'Horiz','left', 'Vert','top', 'Interpreter','latex')
[CH0rfilt,DF] = bandpass(CH0r, [1E-4 6.5E-4], Fs, 'ImpulseResponse','iir'); % Filter Signal
figure
plot(tr, CH0r, '-b')
hold on
plot(tr, CH0rfilt, '-r')
hold off
grid
xlabel('t')
ylabel('Amplitude')
legend('Original (Resampled)', 'Filtered', 'Location','best')
Experiment with the filter types and characteristics to get the result you want. See the documentation for the various functions to understans how they work and the reason I used them here. The data were not sampled with a consistent sampling interval, so it was necessary to use the resample funciton to correct for that.
EDIT — (26 Jul 2021 at 16:01)
Added plot image —
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!