replace one matrix with the positon indicated in another matrix

2 次查看(过去 30 天)
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];

采纳的回答

Bruno Luong
Bruno Luong 2018-11-19

更多回答(1 个)

KSSV
KSSV 2018-11-19
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 ;

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by