MATLAB: Splitting a cell in two.

cell arraysplitvector

Hello, i have a cell struture with different vectors, ( 220×1 double 87×1 double 175×1 double 102×1 double 165×1 double 123×1 double), that i would like to split i 2 cells, where 1st, 3rd.ect. vector goes in the first, and the 2nd, 4thn ect. goes in the second. Not alle my cells are of the same length. Does anybody know of a smart function? Best Regards Anders

Best Answer

MATLAB's indexing is pretty good at doing these kind of things:
A = {vec1,vec2,vec3,vec4...};
B = A(1:2:end);
C = A(2:2:end);
And it does other neat things too: