function [SS]=missss(X)
%[SS]=missss(X)
%Calulates the sum-of-squares of the matrix X.
%X may hold missing elements (NaN's)
X=reshape(X,size(X,1),prod(size(X))/size(X,1));
[inan jnan]=find(isnan(X));
innan=size(inan,1);
for i=1:innan,
  X(inan(i),jnan(i))=0;
end;
SS=sum(sum( (X).^2 ));

