06-01-2011 09:28 AM
Dear all,
I am using "curve fitting " VI to fit my experiment data.
The nonlinear model is y=0.5642*(1+b*(2*(x-c)^2-1))*exp(-((x-c)^2)), where "b" and "c" are two parameters.
After fitting, the parameter "b" sometimes is negative. But I need to set "b" only to be a positive number. However, there is no such option in the curve fitting VI, as shown in the attached figure.
How can I realize this?
Any expert can help me? Thank you very much in advance!
Solved! Go to Solution.
06-01-2011 09:38 AM
Put an absolute value on the output for b from the curve fit.
06-01-2011 11:43 AM
Substitute b=exp(d) into your equation: y=0.5642*(1+exp(d)*(2*(x-c)^2-1))*exp(-((x-c)^2))
Fit for d and c, then calculate b=exp(d). The program can fit d positive or negative while b is alway positive.
-- James
06-02-2011 12:09 AM
Many thanks to aeastet!
I have tried, but I can not put an absolute value on the output for parameters in "curve fitting" VI
There is no such option in the setting of the VI.
If I use y=0.5642*(1+abs(b)*(2*(x-c)^2-1))*exp(-((x-c)^2)), it was prompted that the grammar was wrong.
Also many thanks to drjdpowell !
Your suggestion really works.
Thank you so much for your kind help!
06-02-2011 03:58 AM
By the way, you can extend this to put different constraints on b than b>0:
b > m --> use b = m + exp(d)
b < n --> use b = n - exp(d)
and for both high and low limits you can make use of the arctan function that is always between -pi/2 and +pi/2:
m < b < n --> use b = m + (n-m)(atan(d) + pi/2)/pi
-- James