reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

replace.m (439B)


      1 % Replace.m    Replaces the elements in X taking value V with value v2
      2 %    Note, v1 is a matrix of zeros and ones, and
      3 %          v2 is a scalar; or v2 has same dimension as x -- choose elements.
      4 %
      5 %	To replace all 1's with 0's:  replace(x,x==1,0)
      6 %	To replace all NaN's with 0's: replace (x,isnan(x),0)
      7 
      8 function x = replace(x,v1,v2);
      9 
     10      if size(v2)==[1 1];
     11 	x(v1)=ones(length(x(v1)),1)*v2;
     12      else;
     13         x(v1)=v2(v1);
     14       end;