MATLAB: Finding different length pulses

MATLABpulses

Hi
I have attached a screen shot of some pulses with diiferent lenghts my question is what is the best way clean these up and show them.
Thank You
David

Best Answer

Note that ‘clean them up’ is ever so slightly ambiguous.
Assuming that the objective is to remove some of what might be considered ‘noise’, first calculate the Fourier transform of the signal, then using that information to determine where the ‘noise’ frequencies begin, design a lowpass filter to remove the undesirable higher frequencies. (For all of these, the sam;ing intervals must be constant. If it is not, use the resample function to interpolate them to a constant sampling frequency first.)
The Fourier transform is straightforward (assuming ‘x’ is the signal vector):
Fs = ... ; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
L = numel(x); % ‘x’ Is A Vector
xm = mean(x);
xfft = fft(x - xm)/L; % Subtract Mean & Normalise By ‘L’
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(xfft(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Magnitude')
With that information, use the lowpass function to design the filter, or use command-line arguments in a script to design your own filter. This is straightforward with the Signal Propcessing Toolbox functions.
Related Question