How can I extracting a signal pulse from a data

11 ビュー (過去 30 日間)
Khan Engr
Khan Engr 2018 年 9 月 21 日
編集済み: dpb 2018 年 9 月 25 日
I am basic user of in such coding, I Will be grateful for the help. I have a data file (measured signal) that contains few pulses. I want to extract the first pulse (which is also the highest pulse) from this measured signal and save it as another file for further use. The example is shown in the attachment.I have 50 data files ((measured signal).
I want to extract all the first pulses from these 50 measured signal. There is not very hard requirement for the number of samples extracted related to this pulse, may be start to end (rising zero to falling zero etc) or any thing like this.
  1 件のコメント
dpb
dpb 2018 年 9 月 22 日
Do you have Signal Processing TB? If so, findpeaks will be quite useful here...let us know before we invest time elsewhere.

サインインしてコメントする。

採用された回答

dpb
dpb 2018 年 9 月 23 日
編集済み: dpb 2018 年 9 月 24 日
"extract the first pulse (which is also the highest pulse)"
Presuming you can be assured of the assumption, the first is the max, then it's pretty simple...
[pk,ipk]=max(s); % largest peak, location
ilo=find(s(1:ipk)<pk/2,1,'last'); % lower half-max location
ihi=find(s(ipk:end)<pk/2,1,'first')+ipk; % upper half-max location
pkS=s(ilo:ihi);
ADDENDUM
With the second pdf that looks like baseline-crossing is the desired result,
load('Signal.mat');
[pk,ipk]=max(s); % largest peak, location
BL=0; % set baseline level
ilo=find(s(1:ipk)<=BL,1,'last'); % lower boundary location
ihi=find(s(ipk:end)<=BL,1,'first')+ipk-1; % upper boundary location
pkS=s(ilo:ihi);
See what are results--
>> [ilo,ihi]
ans =
613 682
>> s([ilo ihi]).'
ans =
-8.9407e-12 -0.0004
>>
This is within one element of your location, you can modify the test somewhat by looking for within some eps of BL to get nearest to BL or even interpolate for fractional location or whatever it is thought to be most suitable result.
  10 件のコメント
dpb
dpb 2018 年 9 月 24 日
編集済み: dpb 2018 年 9 月 25 日
There's a "+ipk-1" missing on the location for "ihi"; find is counting from the peak location plus one so the absolute location is from that base point.
You'll have to decide about a thresholding level; as noted in the comments with IA, I just illustrated the search mechanism using FWHM as an example.
If you want more of the peak than that (the pdf is nebulous as to a real definition), you'll have to use a baseline estimate or someother level.
Again, being able to set other parameters in the selection besides a fixed threshold is why I asked about SP Toolbox and findpeaks initially; this is a very simple-minded searching algorithm.
Khan Engr
Khan Engr 2018 年 9 月 25 日
編集済み: dpb 2018 年 9 月 25 日
Thank you very much dpb. Your modified code (below) is working well now :)
load('Signal.mat');
[pk,ipk]=max(s); % largest peak, location
BL=0; % set baseline level
ilo=find(s(1:ipk)<=BL,1,'last'); % lower boundary location
ihi=find(s(ipk:end)<=BL,1,'first')+ipk-1; % upper boundary location
pkS=s(ilo:ihi);
Best regards

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 9 月 22 日
This should do it
mask = signal > 2e-3; % Threshold the signal to find regions higher than 2e-3.
% If you get more than one region, use the code below to get only the largest region, otherwise skip it.
mask = bwareafilt(mask, 1);
maskedSignal = signal(mask);
  4 件のコメント
Image Analyst
Image Analyst 2018 年 9 月 23 日
Yep, you're missing that toolbox.
Khan Engr
Khan Engr 2018 年 9 月 25 日
Thanks for your help, I will try to update my Matlab for IPT.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAI for Signals についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by