function T = EnergyThreshold(A,TPercent,Tcontrol)
switch Tcontrol    
    case 0
        T = TPercent;
    case 1
        A = triu(A);
        Energy = A(:);
        Energy(Energy==0)=[];
        EnergyLen = length(Energy);
        Energy_sort = sort(Energy,'descend');
        num = round(TPercent*EnergyLen)+1;
        T = Energy_sort(num);
end
end