Seperately extract 11th and 21st element of matrix A
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
N/A
el 28 de Ag. de 2022
Comentada: Star Strider
el 28 de Ag. de 2022
Hi,
I took Mathlab programming this semester and am still new to all of this.
So basically, I've been given this matrix A (5x5) as shown below.
A=[17 24 1 8 15; 23 5 7 14 16; 4 6 13 20 22; 10 12 19 21 3; 11 18 25 2 9]
So my question is, how do I extract 11th and 21st element of matrix A?
Thank you.
4 comentarios
dpb
el 28 de Ag. de 2022
<learn_matlab/array-indexing.html> is section in Getting Started doc about addressing arrays including this which is called linear indexing.
If in addition to the example you really were interested in traversing the array by row instead of column, then
M = reshape((1:25).', 5, [])*10;
M=M.'; % transpose first
V = M([11 21])
Respuesta aceptada
Star Strider
el 28 de Ag. de 2022
Movida: Matt J
el 28 de Ag. de 2022
MATLAB generally uses columnwise linear indexing, so:
M = reshape((1:25).', 5, [])*10
V = M([11 21])
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!