use of ismember command and change of corresponding

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)

 Akzeptierte Antwort

Bruno Luong
Bruno Luong am 28 Aug. 2020
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 Kommentare

aa
aa am 28 Aug. 2020
Matlab output is here ...
HI(tf,2)=AB(loc(tf),2
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
Check your mouse/keyboard is working
aa
aa am 28 Aug. 2020
oh great .. this works ... thank you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Variables finden Sie in Hilfe-Center und File Exchange

Gefragt:

aa
am 28 Aug. 2020

Kommentiert:

aa
am 28 Aug. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by