function quant=quantiles(x)
% returns q.25 q.5 and q.75 for data vector x
quant(1:3)=NaN; % initialize
xs=sort(x); % sort data
n=length(xs); % number of data
quant(2)=median(xs); % median is q.50
if (rem(n,2)==0) % if even number of data
   quant(1)=median(xs(1:n/2));
   quant(3)=median(xs(n/2+1:end));
else % is odd
    quant(1)=median(xs(1:(n+1)/2));
    quant(3)=median(xs((n+1)/2:end));
end