Could anyone help me with a code to check if the time intervals intersect
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Catalytic Kys
el 15 de Oct. de 2019
Comentada: Catalytic Kys
el 15 de Oct. de 2019
% 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 comentarios
Respuesta aceptada
Andrei Bobrov
el 15 de Oct. de 2019
M = sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:);
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!