%% Plot Lower Incomplete Gamma Function
% Calculate the lower incomplete gamma function for a = 0.5, 1, 1.5, and 2 within the interval 0 \leq x \leq 10. Loop over values of a, evaluate the function at each one, and assign each result to a column of Y.

A = [0.5 1 1.5 2];
X = 0:0.05:10;
Y = zeros(201,4);
for i = 1:4
    Y(:,i) = gammainc(X,A(i));
end

% Plot all of the functions in the same figure.

plot(X,Y)
grid on
legend('$a = 0.5$','$a = 1$','$a = 1.5$','$a = 2$','interpreter','latex')
title('Lower incomplete gamma function for $a = 0.5, 1, 1.5,$ and $2$','interpreter','latex')
xlabel('$x$','interpreter','latex')
ylabel('$P(x,a)$','interpreter','latex')

% Copyright 2019 The MathWorks, Inc.