% my_script2.m   Example of a script file
%
% Comments at start print in help command, (down to first blank line).  
% Just put in commands as you would at prompt
% Be careful not to use a filename that is already
%  a Matlab¨ command or function name.
% Execute script by typing name without .m

% Create an array of student test scores.
% The columns are for three students.
scores = [96, 85, 93; 23, 56, 1]; % row 1 exam 1, row 2 exam 2

% Calculate average for each exam
display('Ave test scores')

% The mean() function calculates the average of a set of numbers.
m = mean(scores')'  % Use '.  We want  means of rows, but mean operates on cols.

% Now we find the maximum score each student has received on an exam.
%  The next command extracts the max score and which exam it was.
[max_score, max_index] = max(scores)

% Find the overal max exam score and which student it was.
[second_max, second_ind]=max(max_score)

% Determine whether the overall max was exam one or two.
max_index(second_ind)
