
function[fig_num,idx]=plot_num_modes(fig_num,stitle,fc,mph,fmin,fmax)
%
%   idx = first band above which all bands have a least three modes
%

            N=length(fc);

            num=zeros(N,1);

            q=2^(1/6);

            for i=1:N
                fu=fc(i)*q;
                fl=fc(i)/q;
                num(i)=(fu-fl)*mph(i);
            end    

            mask = num >= 3;
            tail_ok = flip(cumprod(flip(mask)));   % 1 where all values from i:end are >= 3
            idx = find(tail_ok, 1, 'first');
            
            if isempty(idx)
                idx = NaN;
            end


            f=fc;
            b=num;
            t_string='Number of Modes per One-Third Octave Band';
            ylab='num';

            [fig_num]=plot_modes_onethird_octave_bar(fig_num,f,b,t_string,ylab);