A is a matrix , what does this statement A([1,end],[1,end]) mean ?
Ältere Kommentare anzeigen
The result of this command gives the 4 corners of the matrix, but can't figure out how that command works
Akzeptierte Antwort
Weitere Antworten (1)
RAVIKIRAN YALAMARTHI
am 30 Jun. 2020
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 Kommentare
Muhammed Thameem
am 1 Jul. 2020
Gianpiero
am 25 Aug. 2022
what does it mean (1:end, 1)?
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
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!