MATLAB: Vector Manipulation – How to achieve this specific form

doublemanipulationMATLABvectorvectors

Hi all,
I want to receive an expression like this: sos = {[1 8761]' [2 8762]' [3 8763]' [4 8764]' … [8760 17520]'};
Do you have an idea on how to achieve this?

Best Answer

Try this:
v1 = 1:17520; % Create Vector
v2 = reshape(v1, [], 2)'; % Reshape Vector To 2-Row Matrix
c = mat2cell(v2, 2, ones(1,size(v2,2))); % Create Cell Array
q1 = v2(:,1:5); % View Original Matrix Sample (Delete Later)
q2 = [c{1:5}] % View Cell Array Sample (Delete Later)
q2 =
1 2 3 4 5
8761 8762 8763 8764 8765
I created separate assignments for clarity. Note that ā€˜cā€™ is a (1x8760) cell array, the format requested.