clear;
close;
clc;
N = 250;
c = randi([0,10],1,N);
b = randi([0,10],1,N);
a = randi([0,10],1,N);
M = randi([1,10],1,N).*1e5;
for i = 1:N
    arr = [a(i),b(i),c(i)];
    [~,Mind] = max(arr);
    [~,mind] = min(arr);
    if Mind ~= 3
        c(i) = arr(Mind);
    end
    if mind ~= 1
        a(i) = arr(mind);
    end
    if mind == Mind
        a(~i);
        b(~i);
        c(~i);
    else
        full = [1,2,3];
        remove = ismember(full,[mind,Mind]);
        middle = full(~remove);
        b(i) = arr(middle);
    end
    if ~(a(i)~=b(i)~=c(i))
        a(~i);
        b(~i);
        c(~i);
    end
end
eq = defHCEQ();
% Trojúhelníkový průběh
for i=1:size(a,2)
    eq.beta = {@(x,y,t,T) 0,@(x,y,t,T) 0,@(x,y,t,T) 0,@(x,y,t,T) (M(i)*t/(b(i)-a(i))-M(i)*a(i)/(b(i)-a(i))).*(t > a(i) & t < b(i))+(M(i)*t/(b(i)-c(i))-M(i)*c(i)/(b(i)-c(i))).*(t >= b(i) & t < c(i))};
    filename = strcat('triangular_a=',num2str(a(i)),'_b=',num2str(b(i)),'_c=',num2str(c(i)),'_M=',num2str(M(i)));
    t = linspace(0,10,1000);
    %plot(t,eq.beta{4}(0,0,t,0),'k');
    %hold on;
    solve_and_save(eq, filename);
end
%M=5e5;
%plot(t,(M*t/3-2*M/3).*(t > 2 & t < 5)+(-M*t/3+8*M/3).*(t >= 5 & t < 8),'r')
%hold off;
% Obdélníkový průběh
eq = defHCEQ();
for i=1:size(a,2)
    eq.beta = {@(x,y,t,T) 0,@(x,y,t,T) 0,@(x,y,t,T) 0,@(x,y,t,T) (M(i)).*(t >= a(i) & t <= b(i))};
    filename = strcat('rectangular_a=',num2str(a(i)),'_b=',num2str(b(i)),'_M=',num2str(M(i)));
    solve_and_save(eq, filename);
end