function polynomy
close all; % zavre vsechna graf. okna
p=[3,2,-7,6,-1,15];
disp(p)
q=[4,0,-1,0];
disp(q)
disp('Koreny polynomu p')
disp(roots(p))
disp('Koreny polynomu q')
disp(roots(q))
disp('Vycisleni polynomu p pro x=2')
disp(polyval(p,2))
disp('Vycisleni polynomu p pro x=0')
disp(polyval(p,0))
disp('Vycisleni polynomu q pro x=2')
disp(polyval(q,2))
disp('Vycisleni polynomu q pro x=0')
disp(polyval(q,0))
disp('Vycisleni polynomu q pro x=2')
disp(4.*(2.^3)-2)
disp('Vycisleni polynomu p pro x od -2 do 2')
x=-2:2;
yp=polyval(p,x);
disp(x)
disp(yp)
disp('Vycisleni polynomu q pro x od -2 do 2')
x=-2:2;
yq=polyval(q,x);
disp(x)
disp(yq)
subplot(2,1,1)
plot(x,yp,'o')
title('3x^5+2x^4-7x^3+6x^2-x+15')
subplot(2,1,2)
plot(x,yq,'*')
title('4x^3-x')
figure
xj=-2:0.1:2;
ypj=polyval(p,xj);
yqj=polyval(q,xj);
subplot(2,1,1)
plot(xj,ypj,'r')
title('3x^5+2x^4-7x^3+6x^2-x+15')
subplot(2,1,2)
plot(xj,yqj,'c')
title('4x^3-x')
hold on
plot(roots(q),[0,0,0],'rs')
hold off
figure
subplot(2,2,1)
plot(roots(p),'gp')
grid
xlabel('Re')
ylabel('Im')
subplot(2,2,3)
compass(roots(p),'g')
subplot(2,2,2)
plot(roots(q),[0,0,0],'rs') % imag. casti reseni q
grid
xlabel('Re')
ylabel('Im')
subplot(2,2,4)
compass(roots(q),'r')
disp('Nasobeni polynomu p,q')
s=conv(p,q);
disp(s)
disp('Deleni polynomu - zkouska')
[v,z]=deconv(s,q);
disp('Vysledek')
disp(v)
disp('Zbytek po deleni')
disp(z)
end

