% funkce pro kontrolu jednoho frekvenčnáho pásma
function [passed, err, lower_lim_out, upper_lim_out] = bandCheck...
         (lower_lim, upper_lim, x_axis, I)

    % kontrola rovnosti mezí
    if (lower_lim == upper_lim)
        messege = sprintf...
('frequency band no.%d error: band limits are equal, can''t be calculated',I-1);
        disp(messege);
        lower_lim_out = lower_lim;
        upper_lim_out = upper_lim;
        passed = 0;
        err = 1;
        return;
    end

    % kontrola jednostlivých případů, které mohou nastat
    if (lower_lim > upper_lim)
        lower_lim_out = upper_lim;
        upper_lim_out = lower_lim;
    else
        lower_lim_out = lower_lim;
        upper_lim_out = upper_lim;
    end
    
    if (lower_lim_out < min(x_axis))
        lower_lim_out = min(x_axis);
    end
    
    if (lower_lim_out > max(x_axis))
        lower_lim_out = max(x_axis);
    end
    
    if (upper_lim_out < min(x_axis))
        upper_lim_out = min(x_axis);
    end
    
    if (upper_lim_out > max(x_axis))
        upper_lim_out = max(x_axis);
    end
    
    if (lower_lim_out == upper_lim_out)
        messege = sprintf...
('frequency band no.%d error: band limits are both above or bellow common frequency band of input graphs, can''t be calculated',I-1);
        disp(messege);
        passed = 0;
        err = 2;
        return;
    end
    
    passed = 1;
    err = 0;

end