function[m] = maxxy(x, y); % % function[m] = maxxy(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 % ------------------------------------------------------------------- % 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)); %iterate over inputs and assign output for i = 1:inputlength if (x(i) > y(i)) m(i) = x(i); elseif (x(i) == y(i)) m(i) = 0; else m(i) = y(i); end; end;