Array Indexing, Array within an Array
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Christopher Wible
el 19 de Jun. de 2019
Respondida: Matt J
el 19 de Jun. de 2019
I need help understanding how this code works.
Consider the variables B = [1 5 8] and D = [1; 1; 1]. When I write the code B(D,:) I am getting the output of [1 5 8; 1 5 8; 1 5 8] and I am not sure why.
Please be thorough in your explination.
Thanks for the help.
0 comentarios
Respuesta aceptada
Matt J
el 19 de Jun. de 2019
Because, by definition,
B(D,:) = [ B(D(1),:) ; B(D(2),:) ; B(D(3),:) ]
= [ B(1,:) ; B(1,:) ; B(1,:) ]
= [1 5 8; 1 5 8; 1 5 8]
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing 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!