


FUNCTION REPLACE finds all the elements of matrix X that are equal to A, and
returns a matrix Y with A values replaced by B.
[y]=replace(x,a,b)
r.p. signell 4-10-90
modified for NaNs in 4.1 9-9-94

0001 function [y]=replace(x,a,b) 0002 %FUNCTION REPLACE finds all the elements of matrix X that are equal to A, and 0003 % returns a matrix Y with A values replaced by B. 0004 % [y]=replace(x,a,b) 0005 % 0006 % r.p. signell 4-10-90 0007 % modified for NaNs in 4.1 9-9-94 0008 y=x; 0009 if(isnan(a)), 0010 ind=find(isnan(x)); 0011 else 0012 ind=find(x==a); 0013 end 0014 if(length(ind)~=0), 0015 y(ind)=b*ones(1,length(ind)); 0016 end