How to fit the data points into a closed curve?

조회 수: 16 (최근 30일)
Wesley
Wesley 2020년 11월 26일
답변: Wesley 2020년 11월 27일
Hello everyone, I’d like to ask you a question. Now I have a series of data points and want to fit these points into a closed curve. But the effect is not good, I would be very grateful if anyone can help me. The data required for closed curve fitting is shown below.
  댓글 수: 3
John D'Errico
John D'Errico 2020년 11월 26일
Please don't use an answer just to make a comment. I've moved your answer into this comment.
John D'Errico
John D'Errico 2020년 11월 26일
What about that data do you want to be a closed curve? No, you cannot use interpolation using tools like interp1 to fit the black curve.

댓글을 달려면 로그인하십시오.

답변 (3개)

Stephan
Stephan 2020년 11월 26일
This will not solve your problem finally, but it shows a possible way to tackle this. The idea here is to use a cardiod curve and find parameters that try to minimize the difference between the single data points:
data = readmatrix('DataFit.xlsx');
a = [72.0839, 1.3643, 338.485, 289.4648, -21];
[x,y] = calcCurve(a);
figure
scatter(data(:,1),data(:,2))
hold on
scatter(x,y)
hold off
function [x,y] = calcCurve(a)
theta = linspace(-pi,pi,1187);
r = @(theta) a(1).*(a(2)+cos(theta));
rho = r(theta);
[x,y] = pol2cart(theta,rho);
x = -x';
y = -y';
xy = sortrows([x,y],1);
x = xy(:,1) + a(3);
y = xy(:,2) + a(4);
end
The parameters for a were found by optimization techniques - maybe this is a local optimum and we could do better. But the point is, that you have to think about your mathematical problem and analyze what you have there. After that it makes sense to start coding:

Wesley
Wesley 2020년 11월 27일
The curve you fit out is a bit larger than the original image. I am thinking of a fitting method that is more appropriate to the original curve. The method described in this article feels very feasible. But I don't know how to implement it with programs. The article is as follows:

Wesley
Wesley 2020년 11월 27일
For convenience, we use this data for closed curve fitting.

카테고리

Help CenterFile 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!

Translated by