A is a matrix , what does this statement A([1,end],[1,end]) mean ?
83 ビュー (過去 30 日間)
古いコメントを表示
The result of this command gives the 4 corners of the matrix, but can't figure out how that command works
0 件のコメント
採用された回答
madhan ravi
2020 年 6 月 30 日
That's equivalent to:
[A(1,1), A(1,end);...
A(1,end), A(end,end)]
https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html - read above linear indexing.
6 件のコメント
Ceethal Kottakali Piyus
2022 年 1 月 20 日
Hey did you mean its equivalent to:
[A(1,1), A(1,end);...
A(end,1), A(end,end)]
or
[A(1,1), A(1,end);...
A(1,end), A(end,end)] because the second option doesn't giving the 4 corners of the matrix
DGM
2022 年 8 月 25 日
@Ceethal Kottakali Piyus, you are correct.
A = magic(5) % an example matrix
A([1,end],[1,end])
[A(1,1), A(1,end); A(end,1), A(end,end)]
@RAVIKIRAN YALAMARTHI's answer may also serve as demonstration.
その他の回答 (1 件)
RAVIKIRAN YALAMARTHI
2020 年 6 月 30 日
Simple example:
A = [1 2 3;4 5 6;7 8 9]
A([1,end],[1,end])
ans = 2 by 2
1 3
7 9
To call the elements in a matrix, we have to mention the row and column index values.
So, A(1,2) = 2. Since, 1st row and 2nd column element is 2.
similarly, A([1,end],[1,end]) will call the elements of,
1st row & 1st column: A(1,1)
last row & 1st column: A(end,1)
1st row & last column: A(1,end)
last row & last column: A(end,end)
3 件のコメント
DGM
2022 年 8 月 25 日
That set of subscripts will address the first column of a matrix.
A = magic(5) % an example matrix
A(1:end,1) % this is the same
A(:,1) % as this
参考
カテゴリ
Help Center および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!