필터 지우기
필터 지우기

could anyone help me to solve the issue.

조회 수: 1 (최근 30일)
jaah navi
jaah navi 2019년 9월 12일
답변: Walter Roberson 2019년 9월 12일
i am having two different array
A = [ 0 2.9985 2.5625 0.7236;
0 0 1.0235 3.0086;
0 0 0 2.8162;
0 0 0 0]
B =[ 2.9985 2.5625 3.0086 2.8162]
I want to display the A array in a way such that number present in B array should be present in A array and the rest of the numbers should be as zero.
the desired output is
A=[0 2.9985 2.5625 0;
0 0 0 3.0086;
0 0 0 2.8162;
0 0 0 0]
Could anyone please help me on this.

채택된 답변

Walter Roberson
Walter Roberson 2019년 9월 12일
A(~ismember(A,B)) = 0;
But since you are using floating point numbers, I highly recommend you use ismembertol() instead of ismember()

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by