Hold and constraints

Hi I'm just wondering if it is possible to hold one variable and constraint another one. I'm doing like below(Hold K0 to a2; K1 varies; K2 constraint to be positive), but it did not work. Thanks for any advice.
                 K0 = a2
        display Ypost vs Xpost
        Make/O/T/N = 1 T_constraints
        T_constraints[0] = {"K2>0"}
        print a2
        CurveFit/Q/H="100" poly 3, Ypost[0,(YCRIT_ind-fit_ind)]/X=Xpost/D/C=T_constraints
        duplicate W_coef poly_coef
The trouble isn't that holding and constraining aren't compatible (they are), but that the built-in linear fits (line, poly, poly2d) can't be constrained. To apply constraints you will have to write a user-defined poly 3 fit function. Something like this:
Function myPoly(w,x) : FitFunc
    Wave w
    Variable x

    return poly(w, x)
End

Copy my function into your Procedure window (Windows->Procedure Windows->Procedure Window). It can fit any order of polynomial; it decides the order based on the number of elements in the coefficient wave. The drawback of this flexibility is that you must make a suitable coefficient wave before opening the Curve Fit dialog. When the dialog complains that it doesn't know how many coefficients there are, go to the Coefficients tab and select your pre-made wave. For the equivalent of Poly 3 built-in fit function you would need a 3-element wave. That gets you a second-order polynomial.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com