Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to use values of a vector as indices for a matrix

1 visualización (últimos 30 días)
Christopher
Christopher el 28 de Feb. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have the 20x20 matrix M and the m-by-3 matrix (two column vectors) L.
The values in the 1st and 2nd column of matrix L are to be used as the m and n indices for the matrix M. I attempt to get the corresponding values in M and insert them into column 3 as follows:
L(:,3)=M(L(:,2),L(:,1));
However, this does not work. What is wrong?

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 28 de Feb. de 2014
L(:,3) = M(sub2ind(size(M),L(:,2),L(:,1)));

La pregunta está cerrada.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by