functionz=cvmgt(x,y,p)%CVMGT Conditional merge of two vectors%% z = CVMGT(x, y, p) return a vector z whose elements are x if p is true% and y otherwise. p, x, and y should be the same shape except that x% and y may be scalars. CVMGT stands for conditional vector merge true% (an intrinsic function for the Cray fortran compiler). It implements% the C++ statement%% z = p ? x : y;z=zeros(size(p));ifisscalar(x)z(p)=x;elsez(p)=x(p);endifisscalar(y)z(~p)=y;elsez(~p)=y(~p);endend