function exhaustiveDV = exhaustive(simpleT2FS)

% function exhaustiveDV = exhaustive(simpleT2FS)
% defuzzifies the simple T2FS exhaustively
%
% SG 310508

matrixSize = size(simpleT2FS);
length = matrixSize(2);
x = 0:1/(length-1):1;

L = simpleT2FS(1,:);
U = simpleT2FS(2,:);

TRS = 0;
totalEmbSets = 2.^length;

for count = 0:totalEmbSets-1
    E = zeros(1,length);
    countBinary = dec2bin((2.^length)+count);
    moduli = mod(countBinary,2);
    for index = 1:length
        if moduli(index+1) == 0
            E(index) = L(index);
        elseif moduli(index+1) == 1
            E(index) = U(index);
        end
    end
    dv = defuzz(x,E,'centroid');
    TRS = TRS + dv;
end

DV = TRS/totalEmbSets;

fprintf('Slices: %0.0f \t\t', length);
fprintf('Defuzzified value: %0.10f \n', DV);
