Trouble using Curve Fitter tool
4 次查看(过去 30 天)
显示 更早的评论
My objective is to take my data, and find the parameters that fit it given the model equation, which is correctly typed in the equation box. I am solving for the parameters, as I said, but am running into the error outputed on the bottom right of the screenshot. MatLab suggesting to utilize upper/lower bounds for my parameters, but I want the parameter values to be returned by the curve fitter, and in addition I do not know how I would go about putting bounds on them even if I did have values for them given that they are supposed to change for each data set that I input.
In addition, if anyone can help me confirm that 'exp' in my equation is registered as e by MatLab, thank you.
Anyone who can help me with my issue, please let me know how I can solve for these parameters. Thanks
3 个评论
Matt J
2023-7-5
编辑:Matt J
2023-7-5
I do not know how I would go about putting bounds on them
How does your model make physical sense unless beta+k2*x and delta+k4*x are both non-zero for all x? There are no singularities apparent in your x,y data.
Also, is n supposed to be an unknown parameter? If so, shouldn't n be non-negative? And is it supposed to be an integer?
回答(1 个)
Matt J
2023-7-5
编辑:Matt J
2023-7-5
I am not sure I understand what you mean regarding apparent singularities in my x,y data.
If beta+k2*x=0 or delta+k4*x=0 then your model equation is undefined, and the curve will have a discontinuity at such points. Moreover, the curve could diverge to
for x immediately to the right and left of those points. However we don't see such bad behavior in the plot of your curve samples.

There is likely some physical reason why beta+k2*x or delta+k4*x are not supposed to change sign over the range of x that you are fitting. Therefore, you will need to incorporate those constraints into your fit. Note that as of R2023a, lsqcurvefit can support arbitrary linear equality constraints like beta+k2*x>=0, so you might want to use that to do the fitting instead.
Yes to all of your questions
Therefore, you are confirming that n is an unknown integer. You cannot have integer constraints using any of the least squares fitting routines in the Curve Fit or Optimization Toolboxes. The simplest thing would be to repeat the curve fit multiple times, each time trying a different value of n=0,1,2,...,N up to some reasonable maximum N, which you would probably know from physical logic. A more complicated approach would be to include n in the list of unknowns, but use a solver like ga which supports integer constraints. For that, you would need to have the Global Optimization Toolbox.
2 个评论
Matt J
2023-7-7
编辑:Matt J
2023-7-7
Your attempts to use lsqcurvefit do not resemble at all the syntax in the documentation (which I provided a link for in my last post). You should definitely read that, as well as the examples there.
Also, please only use screenshots when it is insufficient to type your code as text. Text is easier for us to copy/paste. Ideally also, you would run and demonstrate the code and its problems here in the forum, rather than on your own computer (example below) so we can be sure it isn't a problem in your environment.
a=1+2
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!