Indexing to return segments
古いコメントを表示
Hi. I know this could look like a silly question but can't find a way to do it. I have a matrix (data) that is 14258 x 7, the first six columns are data from a subject and the last column are time markers (0 off and 5 is on).
I used ischange on the last column to have the changing points:
[index,~] = ischange(data(:,7))
The problem is that I should end with 10 segments (of different duration) that include the data of the other 6 columns, but I don't know how to use the index to have it.
Thanks in advance
採用された回答
その他の回答 (1 件)
Bob Thompson
2021 年 1 月 29 日
It looks like the index output is actually a logic array. I recommend using find to identify the actual indexes of the identified changes. I imagine it woud look something like the following, but it is untested:
[index] = find(ischange(data(:,7))==1);
I'm not quite sure how you want to utilize the different sections, but you could capture the different time elements in a cell array kind of like the following:
timedata{1} = data(1:index(1)-1,1:6);
for i = 1:length(index)-1
timedata{i+1} = data(index(i):index(i-1),1:6);
end
timedata{length(index)+1} = data(index(end):end,1:6);
カテゴリ
ヘルプ センター および File Exchange で Timing and presenting 2D and 3D stimuli についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!