Home > omviz > replace.m

replace

PURPOSE ^

FUNCTION REPLACE finds all the elements of matrix X that are equal to A, and

SYNOPSIS ^

function [y]=replace(x,a,b)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003