Say I have a matrix A
A =
 0     1     2
 2     1     1
 3     1     2
and another matrix B
B =
 0    42
 1    24
 2    32
 3    12
I want to replace each value in A by the one associated to it in B.
I would obtain
A =
 42     24     32
 32     24     24
 12     24     32
How can I do that without loops?
 
     
    