필터 지우기
필터 지우기

What does M([1:1 2:3], [1:0 2:3]) mean?

조회 수: 86 (최근 30일)
StillANovice
StillANovice 2020년 8월 21일
답변: Fangjun Jiang 2020년 8월 21일
Hi,
Using a square matrix as an example:
>> M = [1 2 3; 4 5 6; 7 8 9]
M =
1 2 3
4 5 6
7 8 9
I don't understand what does M([1:1 2:3], [1:0 2:3]) do to give the following answer?
>> select = M([1:1 2:3], [1:0 2:3])
select =
2 3
5 6
8 9

채택된 답변

Arthur Roué
Arthur Roué 2020년 8월 21일
This
select = M([1:1 2:3], [1:0 2:3])
is awfully written, it means
select = M(1:3, [2 3])
select is the lines 1 to 3 of M and colum 2 and 3

추가 답변 (2개)

Star Strider
Star Strider 2020년 8월 21일
It is easier to understand if the values are calculated:
row_ref = [1:1 2:3]
col_ref = [1:0 2:3]
produce:
row_ref =
1 2 3
col_ref =
2 3
Note that (1:0) produces:
1×0 empty double row vector
so it is actually redundant here.
.

Fangjun Jiang
Fangjun Jiang 2020년 8월 21일
First, run this line by line in Command Window to figure out what it does
1:5
1:0.5:3
5:-1:1
Then understand that [1:1 2:3] is the same as [1 2 3], [1:0 2:3] is the same as [2 3]
Thus the outcome is the [1 2 3] row and [2 3] column of matrix M

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by