MATLAB: How to set lower and upper bound for only one of the output variable in lsqnonlin

nonlinearoptimization

Hi,
In the documentation of lsqnonlin, following statement is written:
x = lsqnonlin(fun,x0,lb,ub) defines a set of lower and upper bounds on the design variables in x, so that the solution is always in the range lb ≤ x ≤ ub. You can fix the solution component x(i) by specifying lb(i) = ub(i).
How can we write this in case we want to make sure that at the end of optimization, specfic solution components are zero? Problem that I am solving is explained in detail below.
In the problem that I want to optimize, I am using an initial guess to find the location of zero (discontinuity edge) in a data using square root fitting which is not a perfect fit but a rather good guess for intial value (based on the problem and literature that I have read). Now, end goal of the optimization is to find the optimum location for the discontinuity edge. However, the function also has another lsqnonlin in it to find the coefficients around the discontinuity edge which is giving me 4×2 matrix. Values for coefficients at npower = -1 would go to zero at the discountinuity edge.
Is there a way to set the above condition in lower and upper bound for second lsqnonlin function? Attaching the code just in case someone wants to run the function. Following is the line that I used to run lsqnonlin
[cracktip,resnorm] = lsqnonlin(@(X)williamsctip(X,cracklinefit,coefs,v,u,rint,rext),200,170,sqrttip(counter2))
%200 is the initial guess while square root fitting gave us 210.5226. Using this as initial returns the same
%Ideally the edge should lie between 170 to 210.5226 so I selected these as lower and upper bounds.
Cheers,
Waqas

Best Answer

I can't follow all of the details of what you presented but regarding your initial question:
How can we write this in case we want to make sure that at the end of optimization, specfic solution components are zero?
I would suggest just assigning lb(i) = 0 ub(i) = 0 for each of the components that should be held at zero