select data from different data sets

3 visualizaciones (últimos 30 días)
Thar
Thar el 29 de Mzo. de 2019
Editada: Andrei Bobrov el 29 de Mzo. de 2019
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!

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 29 de Mzo. de 2019
Editada: Andrei Bobrov el 29 de Mzo. de 2019
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))) ),:);

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by