Can I store row numbers of a matrix in a column without using any loop?
2 次查看(过去 30 天)
显示 更早的评论
How will I store the first column of a matrix as its corresponding row number without using a loop. That is, the first column for a 3x3 matrix as [1 . .;2 . .;3 . .].
2 个评论
Aquatris
2018-6-29
You mean something like this;
A=[1 5 6; 2 7 8;3 9 0];
B = A(:,1); % this will make B = [1;2;3]
采纳的回答
Nithin Banka
2018-6-29
a = magic(3);
a(:, 1) = [1:3]; % This will store the row index in the first column of 'a'
更多回答(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!