replace one matrix with the positon indicated in another matrix

1 view (last 30 days)
I have two large matrices, for instance
A = [1 3 3 4];
B = [1 2 3 4 ; 5 6 7 8 ; 9 10 11 12 ; 13 14 15 16 ] ;
matrix A represents the postion of numbers of matrix B.
Now how to write B as:
B = [1 3 3 4 ; 5 7 7 8 ; 9 11 11 12; 13 15 15 16];

Accepted Answer

Bruno Luong
Bruno Luong on 19 Nov 2018

More Answers (1)

KSSV
KSSV on 19 Nov 2018
A = [1 3 3 4];
B = [1 2 3 4 ; 5 6 7 8 ; 9 10 11 12 ; 13 14 15 16 ] ;
B(:,2) = B(:,2)+1 ;

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!