how to find nearest date corresponding value ?

조회 수: 31(최근 30일)
pruth
pruth 2019년 10월 17일
댓글: pruth 2019년 10월 17일
Hi, i am really stuck here and can not move ahead !
i have written this code to match the date which works fine as expected.
load('date.mat ');
load('AOD.mat ');
N = AOD_440(:,1);
V = A(:,1);
B = repmat(N,[1 length(V)])
[minValue,closestIndex] = min(abs(B-V'));
closestValue = N(closestIndex);
but here AOD_440 has second column which has some values. so when above code is finding its closest date it should put the corresponding value in second column !
how can we just update the above code ?
or do I need to write different method code ?
i hope you understand the question !
  댓글 수: 2
pruth
pruth 2019년 10월 17일
Thats works fine too !! thanks !

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

채택된 답변

Jos (10584)
Jos (10584) 2019년 10월 17일
Does this return what you want?
R = AOD_440(closestIndex, [1 2]) % select first (date?) and second (values?) columns
  댓글 수: 1
pruth
pruth 2019년 10월 17일
seriously ???? it was that easy ??

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by