Fitting data to a polar equation
Show older comments
I have some data that looks like this: 

I have it in Cartesian coordinates but can convert it to polar coordinates of course. Now I need to fit it to a somewhat messy function of the form shown in the code below using the Curve Fitting Toolbox. The problem is that the function is in polar coordinates, and I have no clue how to write the custom fitting function to work with this (i.e. in the form y = f(x))
Here the fitting parameters should be kappa, k00, k01, etc. Any idea how to do this? The parameters in teh code snipped below are tuned to look somewhat similar to my data, but I need a more accurate fit not done by eye.
A = @(theta, kappa, mu, nu) cos(nu*kappa)*cos(mu*theta);
theta = linspace(0, 2*pi, 500);
kappa = 5.0;
k00 = 1.0;
k01 = 2.0;
k02 = -5.0;
k03 = -1.7;
k31 = 0.0;
k60 = 0.7;
k120 = 0.1;
FS = k00*A(theta, kappa, 0, 0) + k01*A(theta, kappa, 0, 1) + k02*A(theta, kappa, 0, 2) ...
+ k03*A(theta, kappa, 0, 3) + k31*A(theta, kappa, 3, 1) + k60*A(theta, kappa, 6, 0)...
+ k120*A(theta, kappa, 12, 0);
polarplot(theta, FS);
3 Comments
Rik
on 14 Feb 2021
Can you attach your data in a mat file? That way people can try to fit to your actual data.
In the mean time: did you just put the function in the fit function, ignoring that the coordinates or function are in polar coordinates? It might not be optimal, but it should work.
Omar Ashour
on 14 Feb 2021
Edited: Omar Ashour
on 14 Feb 2021
Omar Ashour
on 14 Feb 2021
Edited: Omar Ashour
on 14 Feb 2021
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox 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!
