% NCIAE
% Computer Applications for Engineers
% Assignment 1

close all; clear; clc


% Problem Data

% Problem 8.1
time = 0:24;
temp = [100 101 102 103 103 104 104 105 106 106 106 105 104 103 101 100 99 100 102 104 106 107 105 104 104];

% Problem 8.4
gymnast1 = [9.821 9.923 9.624 9.432 9.534 9.203];
gymnast2 = [9.7 9.925 9.83 9.987 9.354 9.879];


% Place your code for problem 8.1 below this line

% part a
hot_index = find(temp > 105);

% part b
num_hot = length(hot_index);

% part c
time_hot = time(hot_index);

% pard d
cold_index = find(temp < 102);
num_cold = length(cold_index);

% part e
time_cold = time(cold_index);

% part f
perfect_index = find(temp >= 102 & temp <= 105);
time_perfect = time(perfect_index);
% could also use:
% time_perfect = time(temp >= 102 & temp <= 105);

% part g
max_temp = max(temp);


a_8_1_a = hot_index; % Assign your answer to part a to this variable
a_8_1_b = num_hot; % Assign your answer to part b to this variable
a_8_1_c = time_hot; % Assign your answer to part c to this variable
a_8_1_d = num_cold; % Assign your answer to part d to this variable
a_8_1_e = time_cold; % Assign your answer to part e to this variable
a_8_1_f = time_perfect; % Assign your answer to part f to this variable
a_8_1_g = max_temp; % Assign your answer to part g to this variable


% Place your code for problem 8.4 below this line

% part a
gymnast1_wins = length(find(gymnast1 > gymnast2));
gymnast2_wins = length(find(gymnast2 > gymnast1));

% part b
gymnast1_mean = mean(gymnast1);
gymnast2_mean = mean(gymnast2);


a_8_4_a = [gymnast1_wins, gymnast2_wins]; % Assign your answer to part a to this variable
a_8_4_b = [gymnast1_mean, gymnast2_mean]; % Assign your answer to part b to this variable