フィルターのクリア

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 Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by