function rms=nanrms(x,y)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function rms = nanrms(x,y) %
% %
% calculates rms error between 2 files x and y %
% takes only data present in both data sets %
% %
% first dimension contains the data %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mask=isnan(x) | isnan(y);
indy=find(~mask); %finds ones
x=x(indy);
y=y(indy);
%rms=sqrt( (1/size(x,1)) * sum((x-y).^2) );
rms=sqrt((1/length(x)) * sum((x-y).^2) );
if size(x,1)==1
'are you entering the data with the correct shape??', size(x,1)
end