Extracting datas based on date from two datasets

I have two set sets of data where one is 93*2 and other is 609*2. I want to match up the date and extract two different sets of data based on that date. I try this way,
%Retrieve unique sampling period
period = unique(date_LFMC,'rows');
%Build subs for accumarray
[~, subs] = ismember(date_LFMC, period, 'rows');
%Perform accumarray to average FMC
LFMC_avg = period;
LFMC_avg(:,2) = accumarray(subs, Livemoisture_JFSP,[],@nanmean); % 93*2
%Retrieve unique date
period = unique(DateSM,'rows');
%Build subs for accumarray
[~, subs] = ismember(DateSM, period, 'rows');%609*2
%Perform accumarray to calculate average FAW
FAW_avg = period;
FAW_avg(:,2) = accumarray(subs, FAW40,[],@nanmean);
%Assign FAW to each LFMC sample
Data_avg(:,4) = LFMC_avg(:,2);
for i = 1:size(LFMC_avg,1);
for i2 = 1:size(FAW_avg,1)
if Data_avg(i,2) == FAW_avg(i2,1);
Data_avg(i,4) = FAW_avg(i2,2);
end
end
end
I get one sets of data but with another, I am just getting zero. let me know where I did wrong?
Sonisa

댓글 수: 4

dpb
dpb 2016년 9월 29일
No can tell; no data. You are trying to compare to computed values that are presumably not integers so there's a high chance that they don't match to the exact bit if the two arrays each have something in them but the condition in the loop is never satisfied. But, we don't even know that's the problem for certain.
Sonisa
Sonisa 2016년 9월 29일
I am attaching the data files. Day is the common variables. Based on the day, I need to extract A and B. let me know what should I do. A is LFMC_avg(:,2) whereas FAW_avg(:,2) = B.
Thanks.
dpb
dpb 2016년 9월 29일
Have you used the debugger and stepped through your script to see where it goes wrong? Do so and report the symptoms; don't rely on somebody else to do all your debugging for you...
mizuki
mizuki 2016년 10월 2일
How about using datetime format, synchronize/innerjoin/outerjoin function?

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2016년 9월 29일

댓글:

2016년 10월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by