Curve fitting subrange of data

Hello,

I have written a function that does what I want but have ran into difficulties with the curve fitting part of the script.

I would like to fit to the subrange : more_than_zero[index] and max_current[index] ---- how do I properly format this in the CurveFit function?

for(index=0; index<numXYPairs; index+=1)
        String xWaveName = StringFromList(index, new_curr)
        Wave xWave = $xWaveName
        String yWaveName = StringFromList(index, new_cell)
        Wave yWave = $yWaveName
        wave cell_num
        //wave More_than_zero
        //wave max_current
        cell_num[index] =yWave[index]
       
       
        //FitAndGraphXYPair(xWave, yWave)
        Display yWave vs xWave
        ModifyGraph mode=3,marker=19,rgb=(0,0,65535)        // Round blue markers
        DoUpdate
       
        // get x-range that will be used to fit the slope
        Findlevel /Edge=1 /Q /P yWave, 0 ; More_than_zero[index] = V_levelX+1
        WaveStats  /M=2 /Q /R = (0,) yWave; max_current[index]= pnt2x(xWave,V_maxloc)
       

 
 /// fitting to the whole x-range , set /X=xWave
        CurveFit /TBOX=256 line yWave /X= xWave[(More_than_zero[index]),(max_current[index])] /D  
        wave w_coef
        wave w_sigma
        wave cell_num
        slope_fi[index] = w_coef[index]
        error_slope_fi[index]= w_sigma[index]
Please read through the sub-section of the CurveFit reference documentation, "Wave Subrange Details". Basically, it sounds like you are trying to fit yWave[more_than_zero[index], max_current[index]. If you also want the same subrange out of xWave, that's all you need to do:
CurveFit /TBOX=256 line yWave[More_than_zero[index], max_current[index]] /X= xWave /D
If you want different subranges (such as might occur if you want the Y data to be one column of a multi-column wave, and the X data from another column) then you need to specify a subrange on each wave.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com