Skip to content
Permalink
master
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
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