# Fit set of data (x,y) to function with parameter constraints?

10 views (last 30 days)
Shehara Perera on 18 Dec 2017
Commented: Roger Stafford on 18 Dec 2017
Hi!
I'm trying to fit set of (x,y) data to y = D*sin(C*arctan{B*x-E(B*x-arctan(B*x))})
with parameter constraint function
C = 1+(1-(2/pi)*arcsin(F/D))
here B,C,D,E are the parameter constants need to find and F is the asymptote of y as x goes to infinity.
I can curve fit data with cftool for the main equation,
searched in internet but cannot find way to get an answer
How to add the constraint parameter functions ?
Thanks for the help. sorry for my knowledge, I'm new to matlab.

Roger Stafford on 18 Dec 2017
If it is assumed that B*(1-E)>0, then the asymptote of y would be
F = D*sin(C*pi/2)
which gives
C = 2/pi*asin(F/D)
In any case, such a requirement is not really a constraint. Either you vary C or you vary F in making a fit. The one determines the other.
Shehara Perera on 18 Dec 2017
Thanks Roger,
but my problem has more than 20 of coefficients like above(implicit functions).
It's hard to get one equation for all
Any suggestions ?
How to minimize (C-2/pi*asin(F/D)) ?
Roger Stafford on 18 Dec 2017
The point I was making is that you cannot regard both F and C as quantities that can be independently varied while searching for a fit. As I have said, setting one of them will determine the other. That is because as x approaches infinity, arctan(B*x-E(B*x-arctan(B*x))) will of necessity approach pi/2 assuming B*(1-E)>0, and therefore y will approach D*sin(C*pi/2). This shows that F = D*sin(C*pi/2). Therefore you can regard B, C, D, and E as your variable parameters and F will automatically be satisfied. It is not a separate constraint.