function z = add2vectors(a,b) % ADD2VECTORS Sum of two vectors. % z = add2vectors(x, y) adds the vectors x and y. If the vectors % x and y are not the same length, then the smaller vector % is padded with zeros. The sum is stored in a column vector z % with length max(length(x), length(y)). % % Example: If A = [2 3] and B = [1 2 3] then % Z = add2vectors(A, B) % returns Z = [3 % 5 % 3]. % Don Hummels % ECE 486 - Example MATLAB function % January 22, 2008 a = a(:); % Force the two input vectors to be column vectors. b = b(:); % % Check if the two input vectors are the same length. If not % pad the smaller vector with zeros and proceed with the vector % addition. % if (length(a) ~= length(b)) if(length(a)