필터 지우기
필터 지우기

Split 837 x 2 matrix into smaller n x 2 matrices

조회 수: 2 (최근 30일)
Royvg94
Royvg94 2015년 9월 17일
댓글: Royvg94 2015년 9월 17일
I have an 837 x 2 matrix with in the first column time, and in the second column some other values. I would like to split the matrix based on the difference between the time values in the first column.
For example: If you have this matrix:
A = [3 78; 6 52; 9 63; 300 123; 303 143; 306 107; 600 503]
I would like to split it between 9 and 300 and 306 and 600. So lets say if the difference in the first column is bigger than 50. So that i get those matrices out of it:
B = [3 78; 6 52; 9 63] C = [300 123; 303 143; 306 107] D = [600 503]
I already know how to calculate differences between them, now i only need to know how to split the matrices this way.
Thanks for the help!

채택된 답변

Matt J
Matt J 2015년 9월 17일
편집: Matt J 2015년 9월 17일
A = [3 78; 6 52; 9 63; 300 123; 303 143; 306 107; 600 503]
[m,n]=size(A);
z=diff([0,find(diff(A(:,1))>50).',m]);
Acell=mat2cell(A,z,n);
>> [B,C,D]=deal(Acell{:})
B =
3 78
6 52
9 63
C =
300 123
303 143
306 107
D =
600 503

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by