how to equalize row and column values in two matrices

조회 수: 4 (최근 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 CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by