Replace values in an array with values from a single row in another array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Martin Rios
el 6 de Sept. de 2017
Respondida: Guillaume
el 6 de Sept. de 2017
I have two arrays, A of size 96*183106 and B of size 1298*121. Array B is filled with indices of data from array A that I'm interest in. I want to replace all the values in array B with data from the first row only of array A. In other words, each value in B is a specific index of the first row of array A that I want to extract. Given the difference in dimensions I'm guessing I'll have to transform one these arrays but I'm at loss on how to reach my end goal. If anyone could give me some pointers in the right direction I would appreciated it.
0 comentarios
Respuesta aceptada
Guillaume
el 6 de Sept. de 2017
A(sub2ind(size(A), repmat(1, size(B)), B)) %the 1 stands for row 1.
is all that is needed.
This will give you the values in an array the same size as B. You can reshape that in any form you want.
0 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!