Could anyone help me with a code to check if the time intervals intersect

1 vue (au cours des 30 derniers jours)
% 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

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 15 Oct 2019
M = sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:);

Plus de réponses (0)

Catégories

En savoir plus sur Surrogate Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by