replace matrix A with the values of another matrix B
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Elysi Cochin
il 15 Mag 2022
Modificato: Dyuman Joshi
il 15 Mag 2022
Having a matrix A as attached, how to replace all those 1 in A with the values in matrix B, so that i get a new matrix as newA
A(:,:,1) =
0 0 1
0 1 0
0 1 1
A(:,:,2) =
1 0 0
0 0 0
0 0 0
A(:,:,3) =
0 1 0
1 0 1
1 0 0
B = [6 1 5; 2 6 7; 4 6 9];
B =
6 1 5
2 6 7
4 6 9
newA(:,:,1) =
0 0 5
0 6 0
0 6 9
newA(:,:,2) =
6 0 0
0 0 0
0 0 0
newA(:,:,3) =
0 1 0
2 0 7
4 0 0
0 Commenti
Risposta accettata
Bruno Luong
il 15 Mag 2022
Modificato: Bruno Luong
il 15 Mag 2022
A= cat(3, [ 0 0 1;
0 1 0;
0 1 1], ...
[1 0 0,
0 0 0;
0 0 0], ...
[0 1 0;
1 0 1;
1 0 0 ]);
B = [6 1 5; 2 6 7; 4 6 9];
A.*B
0 Commenti
Più risposte (1)
Dyuman Joshi
il 15 Mag 2022
Modificato: Dyuman Joshi
il 15 Mag 2022
A(:,:,1) = [0 0 1; 0 1 0; 0 1 1];
A(:,:,2) = [1 0 0; 0 0 0; 0 0 0];
A(:,:,3) = [0 1 0; 1 0 1; 1 0 0];
B = [6 1 5; 2 6 7; 4 6 9];
newA=A.*B
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!