Filter löschen
Filter löschen

Split 837 x 2 matrix into smaller n x 2 matrices

2 Ansichten (letzte 30 Tage)
Royvg94
Royvg94 am 17 Sep. 2015
Kommentiert: Royvg94 am 17 Sep. 2015
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!

Akzeptierte Antwort

Matt J
Matt J am 17 Sep. 2015
Bearbeitet: Matt J am 17 Sep. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by