How to import data from another structure based on two conditions

2 Ansichten (letzte 30 Tage)
nlm
nlm am 1 Nov. 2018
Bearbeitet: nlm am 1 Nov. 2018
I have two structures. I want to import data from Struct1 into Struct2 based on two conditions Date and Time (which are common in both the structures.) I wanted, if the dates are equal in two structures, and least time difference in their start times then import the data from SAP structure with F1 field into structure New with F1 field.
My code is as follows:
len1 = length(SAP);
len2 = length(New);
for jj = 1: len1
for ii = 1: len2
if New(ii).Date == (SAP(jj).Date)
[a,ind1] = min(abs([(SAP.StartTime)]-New(ii).StartTime))
New(ii).F1= SAP(ind1).F1;
end
end
end
However when I do this, I get the same matrices imported into different dates. What is wrong in my code ?

Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by