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 Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by