How to use 1 column and all rows from a matrix in each iteration?
1 visualización (últimos 30 días)
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 ..
0 comentarios
Respuesta aceptada
Más respuestas (2)
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
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!