pick columns with a index vector
1 次查看(过去 30 天)
显示 更早的评论
Hi I have a 30x100 data matrix and a 1x100 index vector with 1s in some columns and 0 elsewhere. How can I pick up columns in the data matrix corresponding to the 1s in the index vector. Thanks in advance.
0 个评论
回答(1 个)
Azzi Abdelmalek
2014-1-9
编辑:Azzi Abdelmalek
2014-1-9
%Example
A=rand(30,100)
B=randi([0 1],1,100)
%----------------------
out=A(:,logical(B))
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!