fitting a circle with fitnlm
古いコメントを表示
Hello, I tried to fit following data to a circle with help of fitnlm
i used following circle function to determine the center of the circle and the radius:


X = readmatrix('coordinates.txt') %you can find the coordinats.txt in the attachments
circlefun = @(X, b) (X(:,1).^2 + X(:,2).^2 + b(1)*X(:,1) + b(2)*X(:,2) + b(3));
y = zeros(length(X(:,1)),1);
beta0 = [0 0 400];
mdl = fitnlm(X,y,circlefun, beta0)
it gives me following output:
Error using nlinfit (line 219)
MODELFUN must be a function that returns a vector of fitted values the same size as Y (1000-by-1). The model function you provided returned a result that was 1-by-1.
One common reason for a size mismatch is using matrix operators (*, /, ^) in your function instead of the corresponding elementwise operators (.*, ./, .^).
Error in NonLinearModel/fitter (line 1127)
nlinfit(X,y,F,b0,opts,wtargs{:},errormodelargs{:});
Error in classreg.regr.FitObject/doFit (line 94)
model = fitter(model);
Error in NonLinearModel.fit (line 1434)
model = doFit(model);
Error in fitnlm (line 99)
model = NonLinearModel.fit(X,varargin{:});
What I already tried: I used Newton Method for multivariables and the results were quite good in my opinion, but i would like to understand how i can use fitnlm.
Thanks in advance!
採用された回答
その他の回答 (1 件)
Image Analyst
2020 年 7 月 4 日
0 投票
You might also be interested in the FAQ: https://matlab.fandom.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F
1 件のコメント
Hoschang Noori
2020 年 7 月 4 日
編集済み: Hoschang Noori
2020 年 7 月 4 日
カテゴリ
ヘルプ センター および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
