how to equalize row and column values in two matrices

3 Ansichten (letzte 30 Tage)
Raja Zufar
Raja Zufar am 18 Jun. 2020
Kommentiert: Ameer Hamza am 18 Jun. 2020
Hello again, sorry for bothering you gus. I will be very grateful if you guys help me for the code
i have two matrix:
A= [0 3 0 B= [6 5 8]
4 0 0 2 1 7
0 0 8] 3 9 4]
I want B to follow the rows and columns of A:
Boutput = [0 5 0
2 0 0
0 0 4]

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 18 Jun. 2020
Bearbeitet: Ameer Hamza am 18 Jun. 2020
Try this
A = [0 3 0
4 0 0
0 0 8];
B = [6 5 8
2 1 7
3 9 4];
B(A==0) = 0;
Result
>> B
B =
0 5 0
2 0 0
0 0 4
  4 Kommentare
Raja Zufar
Raja Zufar am 18 Jun. 2020
thanks a lot, you save my life again sir :)
Ameer Hamza
Ameer Hamza am 18 Jun. 2020
I am glad to be of help! :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Install Products finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by