Nelem=length(X);
meanX = 0;
index=1;
 
%calculate the X mean
while 1     % Never ending while loop.
   meanX = meanX + X(index);   
   index = index + 1;  % counter updating
   if index > Nelem
       break
   end
end
meanX = meanX / Nelem; 

disp(sprintf('the X mean is %2.2f',meanX));