function MDscaling1(X,names)
%function MDscaling1(X,names)
% matrice X:
% rows are observations
% columns are variables
% names= contiene una stringa di nomi degli oggetti.
%         **non e' necessaria**
%

 if (nargin ==1),
 names=num2str([1:size(X,1)]');
 end
 D=pdist(X,'correlation');

 [Y,stress] = mdscale(D,2,'Criterion','sstress');
%[Y,stress] = mdscale(D,2,'Criterion','sstress','Start','random');
 fprintf('Coeff. di stress in 2D: %f\n',stress) 
 figure(1)
 plot(Y(:,1),Y(:,2),'x')
 text(Y(:,1),Y(:,2),names)
 title('correlation')

 [Y,stress] = mdscale(D,3,'Criterion','sstress');
%[Y,stress] = mdscale(D,3,'Criterion','sstress','Start','random');
 fprintf('Coeff. di stress in 3D: %f\n',stress) 
 figure(2)
 plot3(Y(:,1),Y(:,2),Y(:,3),'x')
 text(Y(:,1),Y(:,2),Y(:,3),names)
 title('correlation')

