MATLAB Answers


How to isolate one pulse from a periodic pulse train

Hans123 님이 질문을 제출함. 20 Jun 2019
최근 활동 Star Strider 님이 댓글을 추가함. 20 Jun 2019
I want to isolate on pulse from this waveform, the data is in a CSV file and the 2 columns contain time data and voltage data.
I want to use a MATLAB code to trim out one full pulse (+peak,zero,-peak,zero)
How can I do this, the peak value is shown using the data cursor

  댓글 수: 2

Use voltage>upper_th & voltage<lower_th??
If you can, can you explain a little further. I need only one pulse out of the 3 in the image. How can I isolate one pulse?

로그인 to comment.

답변 수: 1

Star Strider 님의 답변 20 Jun 2019
 채택된 답변

One approach:
t = linspace(0, 2.3, 500); % Time Vector
pulses = -0.14*sign(sin(5*pi*t/2).*(abs(sin(5*pi*t/2))>0.9)) + rand(size(t))*0.005; % Create Waveform
Mv = pulses > 0.1; % Threshold
Mvs = strfind(Mv, [0 1]); % Start Of Each Pulse
Mve = strfind(Mv, [1 0])+1; % End Of Each Pulse
plot(t, pulses)
hold on
plot(t(Mvs(1):Mve(1)), pulses(Mvs(1):Mve(1)), '+')
hold off
Make appropriate changes to work with your signal.

  댓글 수: 4

표시 이전 댓글 수: 1
My pleasure.
The ‘Mv’ assignment that simply finds values of the function greater than 0.1, and returns a logical vector.
Mvs = strfind(Mv, [0 1]); % Start Of Each Pulse
Mve = strfind(Mv, [1 0])+1;
the ‘Mvs’ and ‘Mve’ assignments detect the beginning and end (respectively) of the pulse by detecting the transition from and in that vector. The use of the strfind function in this context is not at all intuitive, since none oif the arguments are actually strings. It simply works in this context, and is frequently used to find specific sequences in logical vectors.
An equivalent implementation using find and diff would be:
Mvs = find(diff([Mv(1) Mv]) > 0)-1
Mve = find(diff([Mv(1) Mv]) < 0)
The strfind versions are simpler, more efficient, and more flexible in general terms, in that strfind can be used to detect more complex patterns, avoiding more complicated code.
Thanks a lot, I really appreciate your help!
As always, my pleasure!

로그인 to comment.

Translated by