pan>
    frac = n_req/n/2;

    <span class="comment">% The histogram positions to use</span>
    pos = linspace(0.2,0.8,N);

    h = waitbar(0,<span class="string">'Computing...'</span>);
    <span class="keyword">for</span> i=1:N

        <span class="comment">% select data around the histogram position</span>
        centre = pos(i);
        Q = quantile(I,[centre-frac,centre+frac]);
        sel = I &gt;= (Q(1)) &amp; I &lt;= (Q(2));
        sel_data = data(:,sel);
        sel_data = sel_data(2:end,:);

