Skip to content
Permalink
2588d36e56
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
27 lines (23 sloc) 524 Bytes
function r = polyadd(p,q)
%Inputs
% p polynomial coefficent (vector)
% q polynomial coefficent (vector)
%
%Output
% r polynomial coefficent (vector)
% r = p+q
%
if length(p) > length(q)
larger = p;
smaller = q;
else
larger = q;
smaller = p;
end
% diff is a scaler that represents the difference in size of p and q
diff = length(larger) - length(smaller);
%inc is a zero vector with length of the difference of p and q
inc = zeros(1,diff);
smaller = [inc, smaller];
r = larger + smaller;
end