How to curve fit an equation with sigma function
Show older comments
Dear all,
I would like to get coefficient C0, C1....CN from the below equation,

I have enclosed herewith an excel having x and y co-ordinates.
Can anybody please let me know how to write this equation in 'custom equation' option in curve fitting tool or is there any other way to do it?
Answers (2)
Alex Sha
on 27 Jul 2019
1 vote
Hi, where are the values of Z?
1 Comment
Gaurav Nanajkar
on 27 Jul 2019
Catalytic
on 27 Jul 2019
C = polyfit( sqrt( x.^2+y.^2) , Z, N)
4 Comments
Gaurav Nanajkar
on 27 Jul 2019
It's not that polyfit is better or worse at fitting high order polynomials. It's just that high order polynomials are typically a bad thing to use as a model due to numerical instability.
For example the relationship between a polynomial's roots and its coefficients gets unstable at orders higher than about 20, as illustrated below. Notice the errors just in recovering the roots from the coefficients - I haven't even done any curve fitting yet.
>> p=poly(1:20); r=real(roots(p))
r =
19.9999
19.0013
17.9937
17.0185
15.9597
15.0593
13.9302
13.0627
11.9589
11.0225
9.9912
9.0027
7.9994
7.0001
6.0000
5.0000
4.0000
3.0000
2.0000
1.0000
Gaurav Nanajkar
on 28 Jul 2019
As you mentioned as its a higher order polynomial I will not use polyfit due to higher perecentage error.
No, that is not what I said. What I said was "It's not that polyfit is better or worse at fitting high order polynomials. It's just that high order polynomials are typically a bad thing...".
Stop using high order polynomials. Use splines instead.
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!