how to equalize row and column values in two matrices

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

采纳的回答

Ameer Hamza
Ameer Hamza 2020-6-18
编辑:Ameer Hamza 2020-6-18
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by