function q = quartiles( x ) % returns a vector with the first, second, and third quartile of the vector x xs = sort( x ); if ( length( xs ) == 0 ) q = []; elseif ( rem( length( xs ), 2 ) == 0 ) index = length( xs )/2; m = (xs( index ) + xs( index+1 ))/2; q = [ round( xs(length(xs)/4) ), m, xs(round(3*length(xs)/4)) ]; else index = (length( xs ) + 1)/2; m = xs( index ); q = [ round( xs(length(xs)/4) ), m, xs(round(3*length(xs)/4)) ]; end end