finding the closest value
Ältere Kommentare anzeigen
I am working with a very large data set, in which I need to pull numbers from 1 data set that corresponds with a different set. But, if no number from the first data table match the second, then it pulls the next highest number from the second data set.
2 Kommentare
David Hill
am 8 Sep. 2022
Do all numbers in the first data set need a corresponding number from the other data set (either a match or the next largest)?
jason
am 8 Sep. 2022
Akzeptierte Antwort
Weitere Antworten (1)
David Hill
am 8 Sep. 2022
data3=data1;
S=sort(data2);
idx= find(~ismember(data1,data2));
for k=idx
f=find(S>data1(k),1);
data3(k)=S(f);
end
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!