MATLAB: Substituing values of a matrix

matrixsubstituing

Hi everyone! I'm working on substituing values of a matrix with the values of another matrix. So for example, if I had
A = [1 2 3 ; 2 4 5 ; 4 1 3];
V = [1 10 ; 2 20 ; 3 30 ; 4 40 ; 5 50];
I'd like to substitue the values of A that are equal to the values of the first column of V, with the value of the second column of V. For the example, change in A 1 by 10, 2 by 20 and so on. Thank you!

Best Answer

out = reshape(V(A,2),size(A));