function[m, a] = maxxy2(x, y); % % function[m] = maxxy2(x, y); % ------------------------------------------------------------------- % % input: x,y - column vectors % output: m - a column vector of max values between corresponding xs and ys % when x(i) ~= y(i) and 0 otherwise % More efficient version % ------------------------------------------------------------------- % Maxim Likhachev inputlength = size(x,1); %check that the input is valid if(size(x,1) ~= size(y,1) | size(x,2) ~= 1 | size(y,2) > 1) fprintf(1, 'ERROR: size of x should match the size of y or is invalid\n'); return; end; %create output m = zeros(size(x)); a = [x';y']; m = max(a); f = find(x == y); m(f) = 0; m = m';