% Module 2: Lab 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
% 1. Write a function that takes an integer and checks if it is the sum of
% any two squares with brute force. If it is, print the two squares. (2
% pts)
input1 = 13;
[sqr_1_13, sqr_2_13] = check_square_sum(input1);
input2 = 16;
[sqr_1_16, sqr_2_16] = check_square_sum(input2);
%%
% 2. Make bar plot of the functions 1/x, x^2, exp(x) and sin(x) where x
% goes from 1 to 10 in steps of .05. Give your figures titles. (1.5 pts)
data = 1:.5:10;
h1 = figure;
bar(data,1./data);
title('Exponential decay')
xlabel('X')
ylabel('Y = f(X)')
h2 = figure;
bar(data,data.^2);
title('Quadratic growth')
xlabel('X')
ylabel('Y = f(X)')
h3 = figure;
bar(data,exp(data));
title('Exponential growth')
xlabel('X')
ylabel('Y = f(X)')
h4= figure;
bar(data,sin(data));
title('A sinusoid')
xlabel('X')
ylabel('Y = f(X)')
%%
% 3. Write a function that takes in an integer array, sums all its elements,
% prints the sum, and determines if that number is the sum of any two squares.
% Hint: use your solution to problem 2. (1.5 pts)
array = randi(5,5);
[intgr_1, intgr_2] = check_array_square_sum(array);