How to import data from another structure based on two conditions

조회 수: 1 (최근 30일)
nlm
nlm 2018년 11월 1일
편집: nlm 2018년 11월 1일
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 ?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by