%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         10.gyakorlat        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Nemlin. din. rsz-ek alapjai %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        2014.12.03/04        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      Bifurkáció, Ljapunov   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

kezdet=0.2; %0.3; %mindegy honnan indítok kb ugyanaz jön ki;
iteraciok=1000;
mu=0.1:0.001:4;% egész diagram
%mu=3.8:0.00001:3.9; %periodikus ablak 


% Ricker
a=0.1;
mu=0.1:0.01:30; %ez most a "b" paraméter

Population=zeros(length(mu), iteraciok); %adatok ide: sorok: mu-k, oszlopok: iterációk
Population(:,1)=kezdet*ones(length(mu),1); %kezdet minden mu-höz

for i=1:(iteraciok-1) %megcsinálom az iterációt
    %Population(:, i+1)=mu'.*Population(:, i).*(1-Population(:, i));
    Population(:,i+1)=mu'.*Population(:,i).*exp(-a*Population(:,i)); %Ricker

end

%%
size(repmat(mu',[1 101]))   % utolsó száz elemet nézzük -> probléma a mérettel
size(Population(:,900:1000))

Population_derivalt = ;

Ljapunov = ;

%%

figure;
subplot(2,1,1);
plot(mu, Population(:, 0.99*iteraciok:iteraciok), 'b.', 'MarkerSize', 1);
title('Bifurkációs diagram');
xlabel('mu');
ylabel('populáció');


subplot(2,1,2);
%plot(mu,Ljapunov);
hold on;
plot([0,30],[0,0],'r')

title('Ljapunov');
xlabel('mu');
ylabel('populáció');
