フィルターのクリア

meaning of the notation of accessing the elements of the 2D matrix using 4 subscripts?

1 回表示 (過去 30 日間)
Yashvanth L
Yashvanth L 2018 年 6 月 20 日
コメント済み: Stephen23 2018 年 6 月 20 日
Recently, I saw that some people use four sub-scripts to access the elements of a 2D matrix! For eg,If A=[1,2,3,4 ; 5,6,7,8 ; 9,10,11,12 ; 13,14,15,16], then the command, A(1,2,1,1) yields me an answer of 2.
How? What's the meaning of this command? Thanks in advance!!
  2 件のコメント
Jan
Jan 2018 年 6 月 20 日
Writing A(1,2,1,1) is valid, but simply confusing and misleading for the reader.
Stephen23
Stephen23 2018 年 6 月 20 日
"How? What's the meaning of this command?"
All arrays implicitly have infinite trailing singleton dimensions. You can easily check this yourself:
>> size(A,3)
ans = 1
>> size(A,4)
ans = 1
>> size(A,99)
ans = 1
>> size(A,999)
ans = 1
>> size(A,9999)
ans = 1

サインインしてコメントする。

回答 (1 件)

MUHAMMED IRFAN
MUHAMMED IRFAN 2018 年 6 月 20 日
For a 2d Matrix, A(1,2,1,1) is equivalent to A(1,2).
Consider it as A(dimension1,dim2,dim3,dim4). As it is a 2d matrix, the value of dim3,dim4,dim5... will be 1.
ie, A(1,2,1,1,1,1,1,1,1,1) will also give you the value 2 !!
  1 件のコメント
Jan
Jan 2018 年 6 月 20 日
+1. Exactly. In Matlab singleton trailing dimensions are ignored.
x = zeros(2,3,1)
size(x) % [2, 3]
size(x, 9) % 1

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by