use of ismember command and change of corresponding

조회 수: 3 (최근 30일)
aa
aa 2020년 8월 28일
댓글: aa 2020년 8월 28일
Hi everyone,
May someone pleas help me
I want to compare two data set and if match exit then changes the coresspoanding values of second set. For exmaple, in fiorst data set we have values coresspoding to 2, 5 and 8, wheile in second data set we have 0 coresspding to these values. I want to change the coresspodning values of second data set as presented in next columns (H, I)

채택된 답변

Bruno Luong
Bruno Luong 2020년 8월 28일
AB=[2 5 8;
1 6 1]'
DE=(1:10)'*[1 0]
HI=DE;
[tf,loc]=ismember(HI(:,1),AB(:,1));
tf=tf&HI(:,2)==0;
HI(tf,2)=AB(loc(tf),2)
  댓글 수: 3
Bruno Luong
Bruno Luong 2020년 8월 28일
Check your mouse/keyboard is working
aa
aa 2020년 8월 28일
oh great .. this works ... thank you

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by