Search a larger dataset through a smaller data set of intervals
2 views (last 30 days)
Show older comments
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
Answers (1)
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
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!"
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!