function polynomy
close all % zavira vsechna graf. okna
p=[6,3,-7,4,-2,11];
q=[3,0,0,-1,0];
xp=roots(p);
disp('Reseni p=0')
disp(xp)
xq=roots(q);
disp('Reseni q=0')
disp(xq)
subplot(2,2,1)
plot(xp,'rs')
xlabel('Re')
ylabel('Im')
title('6x^5+3x^4-7x^3+4x^2-2x+11')
grid
subplot(2,2,3)
compass(xp,'r')
subplot(2,2,2)
plot(xq,'gp')
xlabel('Re')
ylabel('Im')
title('-x+3x^4')
grid
subplot(2,2,4)
compass(xq,'g')
disp('Vycisleni polynomu p pro x=3')
disp(polyval(p,3))
disp('Vycisleni polynomu p pro x=0')
disp(polyval(p,0))
disp('Vycisleni polynomu q pro x=3')
disp(polyval(q,3))
disp('Vycisleni polynomu q pro x=0')
disp(polyval(q,0))
disp('Vycisleni polynomu p pro x od -2 do 2')
x=-2:2;
disp(x)
disp(polyval(p,x))
disp('Vycisleni polynomu q pro x od -2 do 2')
x=-2:2;
disp(x)
disp(polyval(q,x))
xj=-2:0.1:2;
yp=polyval(p,xj);
figure
subplot(2,1,1)
plot(xj,yp,'k')
xlabel('x')
ylabel('y')
yq=polyval(q,xj);
subplot(2,1,2)
plot(xj,yq,'r')
xlabel('x')
ylabel('y')
pause(2) % pausa 2 sec
close all
disp('Nasobeni polynomu')
s=conv(p,q);
disp(s)
disp(length(s))
disp('deleni polynomu - zkouska')
[v,z]=deconv(s,p);
disp('Vysledek')
disp(v)
disp('Zbytek')
disp(z)
disp('Deleni polynomu p/q')
[v,z]=deconv(p,q);
disp('Vysledek')
disp(v)
disp('Zbytek')
disp(z)
disp('Zkouska po deleni')
disp(conv(v,q)+z)
end

