フィルターのクリア

sum in intervals from columns

1 回表示 (過去 30 日間)
Annick
Annick 2020 年 4 月 2 日
回答済み: Ameer Hamza 2020 年 4 月 2 日
Hello!
I would like to have an code that tells me how much time the subject spent in a certain position (0,1,2).
Currently I have written this code, which tells me how often the value is (0,1,2) but I don't know how to write a code which does what I am looking for.
N= ActivityCode1
Sed_idx= find(N(:,1)==0);
LPA_idx= find(N(:,1)==1);
MVPA_idx= find(N(:,1)==2)
Could you please help me?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 2 日
This code add the intervals corresponding to activities 0,1, and 2. The final matrix is 3x1
t = readtable('Table1.txt');
t(end,:) = []; % last line is invalid
intervals = t.Interval;
activity = t.ActivityCode1;
result = accumarray(activity+1, intervals);

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by