loop a matrix through disorder columns indices
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix A which has 100 rows and 5 columns, I would like to iterate the matrix with disorder indices of columns and save them in each iteration, column indices [2;5;3;4;1]. 1st iteration: get all the rows of A with column 2 then do some processes. 2nd iteration : get all the rows of A with columns 2 and 5. ..... last iteration: get all the rows and columns of A. Anyone helps me to implement it on Matlab environment please.
0 个评论
回答(1 个)
Abderrahim. B
2022-7-31
Hi!
What about this below!
% Dummy A
A = randi(4, 100, 5 ) ;
%
B = [] ;
for cIdx = [2 5 3 4 1]
B = [B, A(:, cIdx )]
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!