function reseni_ukol3(n)
% function reseni_ukol3(n)
% n ... pocet iteraci

% osetreni spousteni bez vstupniho parametru
if nargin < 1
    n = 50000;
end

% zadani pocatecniho bodu
x = [0.5; 0.5];

%vytvoreni grafickeho okna a jeho nastaveni
shg
clf reset
set(gcf,'color','white','menubar','none', ...
'numbertitle','off','name','List')
h = plot(x(1),x(2),'.');           % prikaz pro vykresleni bodu
barva = [0 0.3 0];
set(h,'markersize',3,'color',barva,'erasemode','none');
axis([-3 3 0 10])


drawnow     % prikaz pro vykreslovani v realnem case


i = 0;
while i < n
    i = i + 1;
    r = rand;   % generator pseudonahodnych cisel
    
    if r < 0.85
        x = reseni_ukol2a(x,0.85,-0.05,[0; 1.5]);
    elseif r < 0.92
        x = reseni_ukol2a(x,0.3,1,[0; 1.5]);
    elseif r < 0.99
        x = reseni_ukol2a(x,0.25,-1,[0; 0.5]);
    else
        x = [0 0; 0 0.15]*x;
    end
    
    set(h,'xdata',x(1),'ydata',x(2)); % vykresleni bodu
    drawnow
end



end

% konec
