Search a larger dataset through a smaller data set of intervals

1 view (last 30 days)
I have a time dataset A = 29000x1 and two time datasets Start = 100x1 End = 100x1. I want to run A through the interval I have created with Start and End to end up with a dataset that falls between. I have tried isbetween, I have tried to set a min and max, I have tried a withinrange, but no matter what I do I still get an error that it cannot run because they need to all be the same size. Is there anyway to run a set of data through a time interval that isn't the same size?
  2 Comments
WENDILYN GUIDOTTI
WENDILYN GUIDOTTI on 27 Jan 2023
An example would be data in table A : [8:10:05 8:55:26 8:12:02] Start = [8:10:00 8:11:00 8:40:00] End = [8:10:25 8:12:20 8:45:00] . I was trying to run table A through Start and End intervals so it would return [8:10:05 8:12:02] met the time intervals provided. each row of A needs to go through each time interval Start <= A >= End .

Sign in to comment.

Answers (1)

dpb
dpb on 26 Jan 2023
Edited: dpb on 26 Jan 2023
Taking a wild stab at what might be intended from the above data arrangement; assuming that the larger timetable(?) covers a time span from at least Start(1) through End(end) and that the Start/End arrays define a set of subsets of the total that are wanted to be selected and that these would be disjoint sections. Like, for example, maybe the Start array is the Monday 8AM and End is the corresponding next Friday 5PM??? If it is something like the above, depending upon just what it is that defines the start,stop times, there may be more efficient ways to write the logic, but not having any info on that, we'll just go with what we can guess might be the Q?
B=[];
for i=1:numel(Start)
B=[B;A(isbetween(A,Start(i),End(i)))];
end
The above uses dynamic reallocation because there's insufficient info to know how to preallocate the output array...
  3 Comments
dpb
dpb on 27 Jan 2023
Edited: dpb on 27 Jan 2023
"I added that line to my code..."
One line may not be sufficient depending upon what the other code is; not to mention the above about what the data actually are.
WE NEED TO SEE THE ACTUAL CODE TO QUIT HAVING TO GUESS! The thing is, "we can't debug what we can't see/touch..." and we can't see your terminal from here nor read your mind. "Help us help you!"

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!