replace one matrix with the positon indicated in another matrix

1 visualizzazione (ultimi 30 giorni)
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];

Risposta accettata

Bruno Luong
Bruno Luong il 19 Nov 2018

Più risposte (1)

KSSV
KSSV il 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 ;

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by