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에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!