could anyone help me to solve the issue.

조회 수: 1 (최근 30일)
jaah navi
jaah navi 2019년 8월 6일
댓글: jaah navi 2019년 8월 6일
I am having two matrices
A =[0.2616 0.2642 0.2658 0.2658 0.2641 0.2606;
0.2131 0.1954 0.1776 0.1596 0.1408 0.1209;
0.1023 0.1066 0.1114 0.1162 0.1202 0.1233;
0.5003 0.4596 0.4150 0.3665 0.3148 0.2612]
B =[ 0 2.2721 2.0537 0 0 1.2945;
2.4707 1.3124 1.3201 0 1.5619 0;
1.2997 0 0 1.8159 1.3116 0;
0 0 0 1.3203 0 1.2975]
I want to get a matrix in such a way that all places of 0 in B should be get filled by the values present in A matrix .
The output of the matrix should be
[0.2616 2.2721 2.0537 0.2658 0.2641 0.2606;
2.4707 1.3124 1.3201 0.1596 1.5619 0.1209;
1.2997 0.1066 0.1114 1.8159 1.3116 0.1233;
0.5003 0.4596 0.4150 1.3203 0.3148 1.2975]
could anyone please help me on this.

채택된 답변

Torsten
Torsten 2019년 8월 6일
idx = B==0;
B(idx) = A(idx)
  댓글 수: 3
Torsten
Torsten 2019년 8월 6일
A = ...;
w = ...;
w = logical(w);
B = ...;
A(w) = B(w);
jaah navi
jaah navi 2019년 8월 6일
ok.It works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by