Split 837 x 2 matrix into smaller n x 2 matrices

2 次查看(过去 30 天)
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