フィルターのクリア

how to equalize row and column values in two matrices

1 回表示 (過去 30 日間)
Raja Zufar
Raja Zufar 2020 年 6 月 18 日
コメント済み: Ameer Hamza 2020 年 6 月 18 日
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 件のコメント
Raja Zufar
Raja Zufar 2020 年 6 月 18 日
thanks a lot, you save my life again sir :)
Ameer Hamza
Ameer Hamza 2020 年 6 月 18 日
I am glad to be of help! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by