Following code takes a lot of time to execute. It is done element by element, because it needs iteration. Could it be faster by matrix?
X2=X1; % initialize X2 for irow=1:nrow for icol=1:ncol diff=9999.; for it=1:10 % maximum iteration no. Xout(irow,icol)=1/(1+X2(irow,icol)); % Xout is the output diff=abs(X2(irow,icol)-Xout(irow,icol)); % define difference between iterations if(diff>1.e-5) % require further iteration? X2(irow,icol)=Xout(irow,icol); % initialize the next step else continue end end end end