%Run lvmodel

tspan = [0 100 ];
load_system('lvmodel');
counter = 1;

for i = 100:20:1000
    
    set_param('lvmodel/Gain1', 'gain', num2str(i));
    [t,x,y] = sim('lvmodel',tspan);
   % prey_store{:,:,i} = prey; 
   % figure,plot(prey)
	y = fft(prey,2048);
    %y(1) = 0;
    f = 1000*(0:1023)/2048;
    Pyy = y.* conj(y) / 2048;
    %Pyy(1) = 0;
    HalfPyy = Pyy(1:1024);
    
    for j = 1 : 50
        HalfPyy(j)=0;
    end
    
    %figure, plot(f,HalfPyy);    
    %hold on;

    Peak = max(HalfPyy);
    %Peak    
    index=find(HalfPyy == max(HalfPyy));
    mainPeriodStr=num2str(f(index));
    Period = f(index);
    %plot(f(index),HalfPyy(index),'r.', 'MarkerSize',25);
    %text(f(index)+2,HalfPyy(index),['Period = ',mainPeriodStr]);
    %hold off;
    
     Peak_store(:,counter) = Peak;      
     Period_store(:,counter) = Period;
     X_axis(:,counter) = i;
     counter = counter + 1;
end


figure, plot(X_axis,Peak_store);
figure, plot(X_axis,Period_store);

clear Peak_store;
clear Period_store;
clear X_axis;

