How to use 1 column and all rows from a matrix in each iteration?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(2 个)
Image Analyst
2022-3-4
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!