function B=convertnan(A,x)
// converts Nan's to x
[m,n]=size(A);

for i=1:1:m
  for j=1:1:n
    tt(1,1)=A(i,j);
    xx=thrownan(tt);
    [yy,zz]=size(xx);
    if yy==0
      B(i,j)=x;
    else
      B(i,j)=A(i,j);
    end;
  end;
end;

endfunction;

