How should I use the function Circfit ?
显示 更早的评论
采纳的回答
From the help section of that file,
% x,y are column vector where (x(i),y(i)) is a measured point
Their class are double.
They are column vectors of any length but must have the same length between x and y.
Demo
Here's a demo; see the inline comments to understand each step.
First, compute noisy circle coordinates for the demo.
% Create noisy circle coordinates
radius=3;
theta=linspace(0,2*pi,200);
theta(randi(numel(theta),1,190)) = []; % remove some data
x=radius*cos(theta);
y=radius*sin(theta);
% add noise
x = x + (rand(size(x))-0.5)*radius/4;
y = y + (rand(size(y))-0.5)*radius/4;
% Plot it
plot(x,y,'o')
axis equal
Do the fitting but you have to fill in the inputs. The reason I'm not telling you what the inputs should be is not to cause frustration but to get you to think about this. Again, the two inputs are column vectors of your x and y coordinates of each point you're fitting.
% Fit it
[xc,yc,R,a] = circfit(___, ___); % FILL IN THE INPUTS HERE
% [update: here's the solution: [xc,yc,R,a] = circfit(x, y);
Now you can use the outputs to compute the fitted circle and plot it.
% compute circle based on fit params
theta=linspace(0,2*pi,200);
xFit=R*cos(theta) + xc;
yFit=R*sin(theta) + yc;
% add fit
hold on
plot(xc,yc,'rx') % plot circle center
plot(xFit,yFit, 'r-')

9 个评论
What length ? if I have to find the circumcircle of 3 points with their x and y , how do I write the command ?
x and y would be the x and y values of the 3 points. So, they would have length 3 if you only have 3 points.
Try it. If it doesn't work, show me what inputs you tried and I can help straighten it out.
I'm asking if I have 3 coordinates what should I put instead of circLocs
[centerLoc, circleNormal, radius] = CircFit3D(circLocs)
should I do
[centerLoc, circleNormal, radius] = CircFit3D(x1,y1,x2,y2,x3,y3) ?
if not , please write the line, I don't get it from the incomplete documentation, and nothing on internet
The syntax is
[xc,yc,R,a] = circfit(x,y)
where x and y are column vectors describing the x and y points along the circumference.
You said you have 3 (x,y) coordinates. So x and y each have 3 elements.
I've gotten that from the documentation which I would not call 'incomplete'.
what do you mean ? shall you please write it , how you understood ? are you sure it works ?
I don't understand your definitions, please write the line, why are you making me wait for longer time ?
I have already exhausted my guesses, if you know, why are you refraining ?
I've updated my answer, see the demo I've provided.
why a vector? and how can the vector length be the same for different points?
I justice don't get it
Run my example. The x and y variables are vectors and together they are the coordinates of each noisy point along the cirlce. They are the variables you are fitting.
If you are only fitting 3 points, then your x vector will have 3 values (the x value for each point) and your y vector will have 3 values (the y value for each point).
@farzad, in case you still haven't figured it out, I've updated my answer to show what the two inputs should be to circfit().
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Language Support 的更多信息
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
