global T

% constant lambda
%valLambda = 0.5;

cd(TRAINDIR);

distances = [];

for i=1:size(trainingSet,1),

	name2 = char(trainingSet(i));
    % loads the curve variable
	load(name2);
	curve2 = curve;

    disp(sprintf('processing curve1 and %s...', name2));
    % get T values
    process;
    [m, n] = size(T); 
    distance = T(end, end) - valLambda*sqrt(m*m + n*n)
    distances = [distances; distance];
%    fprintf(FID, '%s \t %s \t %f \n', name1, name2, distance);

end
cd ..

[minimumDistance, idx] = min(distances);
curveFileName = char(trainingSet(idx));
msgbox(sprintf('I recognize the shape as a %s', curveFileName(1:end-4)), 'Recognition result');
