필터 지우기
필터 지우기

how to assign numbers to each row of a matrix? knowing that my matrix is 70x4 so that each row has an index from 1 to 70. Thank's

조회 수: 4 (최근 30일)
antennaSubset =
1 2 3 4
1 2 3 5
1 2 3 6
1 2 3 7
1 2 3 8
1 2 4 5
1 2 4 6
1 2 4 7
1 2 4 8
1 2 5 6
1 2 5 7
1 2 5 8
1 2 6 7
1 2 6 8
1 2 7 8
1 3 4 5
1 3 4 6
1 3 4 7
1 3 4 8
1 3 5 6
1 3 5 7
1 3 5 8
1 3 6 7
1 3 6 8
1 3 7 8
1 4 5 6
1 4 5 7
1 4 5 8
1 4 6 7
1 4 6 8
1 4 7 8
1 5 6 7
1 5 6 8
1 5 7 8
1 6 7 8
2 3 4 5
2 3 4 6
2 3 4 7
2 3 4 8
2 3 5 6
2 3 5 7
2 3 5 8
2 3 6 7
2 3 6 8
2 3 7 8
2 4 5 6
2 4 5 7
2 4 5 8
2 4 6 7
2 4 6 8
2 4 7 8
2 5 6 7
2 5 6 8
2 5 7 8
2 6 7 8
3 4 5 6
3 4 5 7
3 4 5 8
3 4 6 7
3 4 6 8
3 4 7 8
3 5 6 7
3 5 6 8
3 5 7 8
3 6 7 8
4 5 6 7
4 5 6 8
4 5 7 8
4 6 7 8
5 6 7 8

채택된 답변

Steven Lord
Steven Lord 2021년 6월 21일
You already have, by storing your data in a matrix.
A = magic(5)
A = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
% Data associated with the number 3
A(3, :)
ans = 1×5
4 6 13 20 22
If you have different requirements for your numbering that the row indices do not satisfy, please state those requirements.
  댓글 수: 10
Scott MacKenzie
Scott MacKenzie 2021년 6월 21일
편집: Scott MacKenzie 2021년 6월 21일
Yes, this is doable. To show the entire matrix with the line number (row index) shown first on each line:
>> n = 5;
>> A = magic(n);
>> [(1:n)' A]
ans =
1 17 24 1 8 15
2 23 5 7 14 16
3 4 6 13 20 22
4 10 12 19 21 3
5 11 18 25 2 9

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by