select data from different data sets
1 回表示 (過去 30 日間)
古いコメントを表示
Hi all.
I have two data sets looks like (year doy time value1 error):
dataset1:
2015 12 10.44 371 4.32
2015 12 11.45 289 3.25
.
.
.
2019 38 16.56 456 1.78
dataset2:
2015 12 10.44 385 1.35
2015 12 11.89 256 6.52
.
.
.
2019 38 16.56 587 3.74
All values of the time are not the same in the two datasets. I want to keep the data with the smallest error in the common hour in the two data sets and the other data wich are not have the same time as they are.
I want this:
2015 12 10.44 385 1.35
2015 12 11.45 289 3.25
2015 12 11.89 256 6.52
.
.
.
2019 38 16.56 456 1.78
Any ideas?
Thank you!
0 件のコメント
回答 (1 件)
Andrei Bobrov
2019 年 3 月 29 日
編集済み: Andrei Bobrov
2019 年 3 月 29 日
dat1 = [2015 12 10.44 371 4.32
2015 12 11.45 289 3.25
2019 38 16.56 456 1.78];
dat2=[2015 12 10.44 385 1.35
2015 12 11.89 256 6.52
2019 38 16.56 587 3.74];
d = [dat1;dat2];
[~,~,c] = unique(d(:,1:3),'rows');
T = sortrows( array2table([d,c]),'Var6');
ii = varfun(@(x)x == min(x),T(:,5:6),'G',2);
out = T(ii{:,end},1:end-1);
or
d = [dat1;dat2];
[~,~,c] = unique(d(:,1:3),'rows');
out = d(accumarray(c,(1:size(d,1))',[],@(x) x(d(x,5) == min(d(x,5))) ),:);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!