% Example 9.4
% This shows how to get the quartiles using Tukey's method.

load geyser
% First sort the data.
geyser = sort(geyser);
% Get the median.
q2 = median(geyser);
% First find out if n is even or odd.
n = length(geyser);
if rem(n,2) == 1
    odd = 1;
else
    odd = 0;
end
if odd
    q1 = median(geyser(1:(n+1)/2));
    q3 = median(geyser((n+1)/2:end));
else
    q1 = median(geyser(1:n/2));
    q3 = median(geyser(n/2:end));
end
    