How to use 1 column and all rows from a matrix in each iteration?
Mostrar comentarios más antiguos
How to use 1 column and all rows from a matrix in each iteration?
For an example there is a matrix 'M' and its size 7*127 , I want to use in the first iteration the first column and all rows , in the second iteration , I want to use the 2nd column and all rows and so on ..
Respuesta aceptada
Más respuestas (2)
A=randi(100,7,127); % genrating random matrix
C=cell(1,size(A,2));
for i=1:size(A,2)
C{i}=A(:,i);% in each iteration all rows and single column
end
output=[C{:}]
1 comentario
M
el 4 de Mzo. de 2022
Image Analyst
el 4 de Mzo. de 2022
No need to complicate things with cell arrays. Simply extract the column into a column vector that you can then use in whatever computations follow, like for example
for col = 1 : size(M, 2)
% Extract a single column into a new column vector variable.
thisColumn = M(:, col);
% Now use that variable somehow, like in a custom function
% ProcessSingleColumn() that you write.
% Save results into another array called someValue.
someValue(col) = ProcessSingleColumn(thisColumn);
end
1 comentario
M
el 4 de Mzo. de 2022
Categorías
Más información sobre Parallel Computing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!