フィルターのクリア

How to extract signal segments from a long signal given each segment's start and end points

2 ビュー (過去 30 日間)
Hello,
I have a about 10-min signal sequence from the sensor, it looks like this:
And I have labeled many sequence in this signal, the start-end point (time point) of each segment look like this:
(ROI limits here are with second unit, the sample frequency = 50Hz )
Now I want to extract each segment as a vector without doing this by manually typing in their start-end point (ROI limits), so how can I do that?
I have an idea, which is using cell array to store those segments, but I don't know how to do that, may be using a loop, but how should I index them? Thanks!

採用された回答

Star Strider
Star Strider 2022 年 4 月 26 日
Perhaps —
First load ‘Time’ and ‘combinedAccel_01’ and ‘ROILimits’ into the workspace.
Then extract them to a cell array:
for k = 1:size(ROILimits,1)
idxrng = ROILimits(k,1) : ROILimits(k,2);
ROI{k} = [Time(idxrng) combinedAccel_01(idxrng)];
end
That should produce a cell array of column vectors of the time and data vectors.
Make appropriate changes depending on how the data are imported. Without hjaving them to work with, this is as far as I can go with the code.
.
  2 件のコメント
yuh zhang
yuh zhang 2022 年 4 月 26 日
hello, I have solved this problem using the script you provided, thank you very much!
but I modified it a little bit, that is, the ROILimits is measured in time(s), I used function round(ROILimits), so that it can be indexed. Thanks again!
Star Strider
Star Strider 2022 年 4 月 26 日
As always, my pleasure!
Rather than rounding, one option could be:
for k = 1:size(ROILimits,1)
idxrng = (Time >= ROILimits(k,1)) & (Time <= ROILimits(k,2));
ROI{k} = [Time(idxrng) combinedAccel_01(idxrng)];
end
The ‘idxrng’ variable is now a logical vector that can be used to reference the respective rows.
.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 4 月 26 日
Can you extract value and then pass it to findgroups()? Then use that to extract the groups, like with indexing or the bwlabel() function. Attach your data if you need more help, but after reading this:
  1 件のコメント
Image Analyst
Image Analyst 2022 年 4 月 26 日
Maybe if you want to do stats on each group you can use splitapply(), grpstats(), or groupsummary().

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by