% Get the maximum value in a vector
clear
x = [5 -1 4 6 -1 -1 0 6 -9];
% Put the first person in the chair.
xmax = x(1);
% Loop over the remaining people. Note that this loop starts at 2 because
% we have already accounted for the first person
for i = 2:length(x)
%
% Compare the next person x(i) with the person in the chair and reset if necessary
if(x(i) > xmax)
xmax = x(i);
end
end
disp('Max value')
xmax