        c = 0;

        <span class="keyword">if</span> fit_offset
            initial_guess = [1 1];
        <span class="keyword">else</span>
            initial_guess = 1;
        <span class="keyword">end</span>

        [o,f] = fminsearch(@objt,initial_guess);

        counts_per_photon(i) = o(1);
        <span class="keyword">if</span> fit_offset
            offset(i) = o(2);
        <span class="keyword">else</span>
            offset(i) = 0;
        <span class="keyword">end</span>
        waitbar(i