loop for extracting columns of a matrix
3 次查看(过去 30 天)
显示 更早的评论
I would like to know how to do a loop to extract all the columns from a matrix and generate individual vectors
Thanks to all
2 个评论
Adam
2015-4-21
What are you going to do with the individual vectors when they are no longer in the matrix?
Almost certainly anything you want to do would be better off having them all within the matrix and run whatever your vector-based operation is in a for loop if it cannot be vectorised.
回答(1 个)
Chris McComb
2015-4-21
If you have a matrix, M, you can access column i (as a vector) by using M(:, i).
(The colon indicates 'every row')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!