Hi, I am really new in Matlab and coding so I hope somebody can help me. I have a cell array where the first column is the start time and the 2nd is the endtime (dd.MM.yyyy_HH:mm:ss) and some other columns with further information called GivenData.
I have another cell array (eq. 170000×180), which is a SQL-Database-import. The 2nd column here is the time of documentation the others are further information.
(i made the array smaller for testing purpose)
at this point i generated empty columns at the end of the Database, which I want to fill in the right time domains
For Example: GivenData(2,3) should be written in Database(5:10,173) GivenData(2,4) should be written in Database(5:10,174) end so on
GivenData(3,3) should be written in Database(29:35,173) GivenData(3,4) should be written in Database(29:35,174)
for every row in GivenData the Database should get every information in the right time domain.
I usually wiold just do a bunch of for loops. But I have the feeling this is not that easy with matlab, besides it would take the whole night to fill the database.
I tried something like that
for k=2:size(GivenData,1)-1 ta=datetime(GivenData(k,1), 'InputFormat','dd.MM.yyyy_HH:mm:ss'); te=datetime(GivenData(k,2), 'InputFormat','dd.MM.yyyy_HH:mm:ss'); for L=2:size(GivenDB,1)-1; tlower=datetime(GivenDB(L,2),'InputFormat','dd.MM.yy HH:mm:ss.SSSSSS'); tupper=datetime(GivenDB(L+1,2),'InputFormat','dd.MM.yy HH:mm:ss.SSSSSS'); if(isbetween(ta,tlower,tupper)==1) ta=L; break end for m=2:size(GivenDB,1)-1; tlower=datetime(GivenDB(L,2),'InputFormat','dd.MM.yy HH:mm:ss.SSSSSS'); tupper=datetime(GivenDB(L+1,2),'InputFormat','dd.MM.yy HH:mm:ss.SSSSSS'); %
if(isbetween(te,tlower,tupper)==1) te=L; break else te=size(GivenDB,1); for n=3:size(GivenData,2) p=rowstart+1:size(GivenDB,2); GivenDB(ta:te,p)=GivenData(k,n); end end end endend
Basically I tried to find out the in which row my start time begins and in which it ends to fill this. But it seems I cant have multiple variables. So basically I have nothing. I would really appreciate if someone had some suggestions.
I hope I could explain the problem well enough.
Best Answer