Array indexing in matlab

조회 수: 7 (최근 30일)
Christa Weber
Christa Weber 2023년 1월 13일
편집: Voss 2023년 1월 13일
Starting with
>> z = reshape([1:1:30],6,5)'
z =
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
what is the one-line command to access access the variable z to get the result:
1 2 23 24
7 8 29 30

채택된 답변

Voss
Voss 2023년 1월 13일
편집: Voss 2023년 1월 13일
z = reshape(1:30,6,5).' % [] not necessary; 1:1:30 is the same as 1:30; .' is transpose, ' is complex conjugate transpose
z = 5×6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[z([1 2],[1 2]) z([end-1 end],[end-1 end])]
ans = 2×4
1 2 23 24 7 8 29 30

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by