Could anyone help me with a code to check if the time intervals intersect
1 次查看(过去 30 天)
显示 更早的评论
% This script should select the optimal time intervals, so that as many time intervals fit without intersecting each other.
clear;
close all;
clc;
list = [
10 20; % Time intervals: (start day [space] end day) (starts at day 10 ends at day 20 of the year)
9 15;
16 17;
21 100;
];
list_ordered = sortrows(list)
% Check which time intervals overlap:
% 10 20 [9 15, 16 17]
% 9 15 [10 20]
% 16 17 [10 20]
% 21 100 []
% Remove the time intervals with the most intersections:
% 9 15
% 16 17
% 21 100
0 个评论
采纳的回答
Andrei Bobrov
2019-10-15
M = sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!