How to filter a sensor-measured signal to its theoretical form
4 views (last 30 days)
Show older comments
Hello,
I used sensors to measure EMG signals, and it looks like this: (the original data is attached)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/984460/image.jpeg)
However, its theoretical form is this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/984465/image.png)
That is, it seems the lab measured data is subjected to some bias. How can I remove that bias?
Thank you very much if you could answer me this question!
0 Comments
Accepted Answer
Star Strider
on 1 May 2022
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/984450/1.txt', 'VariableNamingRule','preserve')
s1 = T1.Var1;
s2 = T1.Var2;
Fs = 1; % Sampling Frequency (Use The Correct Value)
L = size(T1,1);
t = linspace(0, L-1, L)/Fs; % Time Vector
figure
plot(t, s1, t, s2)
grid
legend('s_1', 's_2', 'Location','best')
Fn = Fs/2; % Nyquist Frequency
NFFT = 2^nextpow2(L); % Efficient 'fft' Length
FTs1s2 = fft([s1 s2]-mean([s1 s2]),NFFT)/L; % Fourier Transform (Subtract 'mean' To Show Peaks More Clearly)
Fv = linspace(0, 1, NFFT/2-1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTs1s2(Iv,:))*2)
grid
xlabel('Frequency')
ylabel('Amplitude')
legend('s_1', 's_2', 'Location','best')
xlim([0 0.15*Fs])
s1s2_filt = highpass([s1 s2], 0.02*Fs, Fs, 'ImpulseResponse','iir');
figure
subplot(2,1,1)
plot(t, s1s2_filt(:,1))
grid
% xlabel('Time')
ylabel('Amplitude')
title('s_1')
subplot(2,1,2)
plot(t, s1s2_filt(:,2))
grid
xlabel('Time')
ylabel('Amplitude')
title('s_2')
.
2 Comments
Star Strider
on 2 May 2022
I very much appreciate your compliment!
As always, my pleasure!
That frequency was chosen because it includes the first peak at about 0.025*Fs and everything greater than that. (There is no significant high-frequency noise, so a bandpass filter is not necessary with this signal.) You can experiment with other frequencies (between 0.01*Fs and 0.02*Fs) to see if that produces any better results.
It would be straightforward to also experiment with a bandpass filter. The upper frequency should likely be in the range of 0.04*Fs to 0.1*Fs for best results, depending on the result you want. This would eliminate what little high-frequency noise that exists in the signal, and depending on the chosen frequency, will also elimiinate all or part of the other two peaks (referring to the fft plot).
.
More Answers (0)
See Also
Categories
Find more on Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!