How to use 1 column and all rows from a matrix in each iteration?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (2)
Image Analyst
on 4 Mar 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
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!