フィルターのクリア

How to extract data from two separate tabs

3 ビュー (過去 30 日間)
Sam
Sam 2021 年 1 月 21 日
編集済み: Matt Gaidica 2021 年 1 月 22 日
I have heart rate and time in two columns. I am going to filter heart rates above 95 bpm. However, in another two columns I have certain "events" that occurred throughout the recording and the times the events occurred. The time of the events don't necessarily match up with the time of the heart rates I want to extract. Tips on creating a script to filter out the heart rates above 95 along with the event that precedes the high heart rate??

回答 (1 件)

Matt Gaidica
Matt Gaidica 2021 年 1 月 22 日
The easiest way to think about this would be using a simple series find statements and the returned indexes to do time comparisons, as well as pull event type.
Post a sample of your actual data, I can imagine some caveats and best practices depending on how it's formatted.
  4 件のコメント
Sam
Sam 2021 年 1 月 22 日
編集済み: Sam 2021 年 1 月 22 日
Thanks for the guidance. I attached the file below in case you have any more thoughts. My goal is to filter out heart rates above 95, just for this particular exampmle, and then the event codes/times that precede it. I appreciate the help! I tried the tutorials, but I wasn't sure how to get started. Anyway thanks
Matt Gaidica
Matt Gaidica 2021 年 1 月 22 日
編集済み: Matt Gaidica 2021 年 1 月 22 日
Sure thing. Try this:
hrIds = find(Data{:,'Heart Rate'} > 95);
hrTimes = Data{hrIds,'Heart Rate Times'};
eventCodes = NaN(1,numel(hrTimes));
for ii = 1:numel(hrTimes)
precTimeId = find(Data{:,'Event Times'} < hrTimes(ii),1,'last');
if ~isempty(precTimeId)
eventCodes(ii) = Data{precTimeId,'Event Code'};
end
end
You have some heart rate times that come before the first event, so those are left as NaN.

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

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by