How to copy all cell array row to other cell row

18 views (last 30 days)
How to copy all cell array row to other cell row?
Because I can only copy one rows one cell at a time.
A = [1 2;3 4;5 6; 7 8; 9 10; 11 12];
Y = {};
Acell = [];
for Nr = 1:6
Acell{Nr} = A(Nr, :);
end
B = nchoosek(Acell,2)
C = B{1,:};
Y{1,1}=B{1,1}
Y{1,2}=B{1,2}
Y{2,1}=B{2}

Accepted Answer

DGM
DGM on 22 Nov 2021
Edited: DGM on 22 Nov 2021
Something like this
A = [1 2;3 4;5 6; 7 8; 9 10; 11 12];
Acell = num2cell(A,2); % don't need the loop
B = nchoosek(Acell,2);
%C = B{1,:}; % idk what this is for
Y = cell(5,2); % or whatever size
Y(1,:) = B(1,:); % no curly braces here
Y(2,:) = B(2,:)
Y = 5×2 cell array
{[ 1 2]} {[ 3 4]} {[ 1 2]} {[ 5 6]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
% ... and so on

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!