I know how to make vectors add such as x=[1 2 3] and y=[-1 2 -1] and it should return as [0 4 2] But when adding two different length vectors such as x=[1 2 3 4 5] and y=[-1 -2 3[], then y should first be transformer to [0 0 -1 -2 3] and the function returns as [1 2 2 2
function y = adding(a,b)if length(a) == length(b), y=b+a; endif length(a) < length(b), y=a+ zeros(1,length(a)-length(b)); endif length (a) > length(b), y=b+ zeros(1,length(b)-length(a)); endend
Best Answer