Converts a list of a polynomials roots to the polynomials coefficients

R2C_demo.m

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a demo for the use of the function Roots2Coeff.
N = 200 ;
Orig_Coeff = randn(1,N) ;
R = roots(Orig_Coeff) ;
Rec_Coeff_poly = poly(R) ;
Rec_Coeff_new = Roots2Coeff(R) ;
figure(1) ; % The plotted coefficients are normilized so that the first coefficient is 1.
plot(1:N,Orig_Coeff./Orig_Coeff(1),'.'); hold on; plot(1:N,Rec_Coeff_poly./Rec_Coeff_poly(1),'+r') ;
title('Reconstruction With poly','FontSize',15);
legend('Original Coeff.','poly-reconstruction') ;
figure(2); % The plotted coefficients are normilized so that the first coefficient is 1.
plot(1:N,Orig_Coeff/Orig_Coeff(1),'.'); hold on; plot(1:N,Rec_Coeff_new./Rec_Coeff_new(1),'+r') ;
title('Reconstruction With Roots2Coeff','FontSize',15);
legend('Original Coeff.','Roots2Coeff-reconstruction') ;