how to equalize row and column values in two matrices

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]

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 18 de Jun. de 2020
Editada: Ameer Hamza el 18 de Jun. de 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 comentarios

Raja Zufar
Raja Zufar el 18 de Jun. de 2020
Editada: Raja Zufar el 18 de Jun. de 2020
how to create new variabel? like Boutput
Boutput= [0 5 0
2 0 0
0 0 4]
Like this
A = [0 3 0
4 0 0
0 0 8];
B = [6 5 8
2 1 7
3 9 4];
Boutput = B;
Boutput(A==0) = 0;
thanks a lot, you save my life again sir :)
I am glad to be of help! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Preguntada:

el 18 de Jun. de 2020

Comentada:

el 18 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by