# Circle Fit at the Corner of the Step??

11 visualizaciones (últimos 30 días)
Swati Jain el 15 de En. de 2018
Comentada: Swati Jain el 22 de En. de 2018
Hi,
I have a step curve (figure 1) and I want fit a circle to each corner of step (shown in figure 2). I wrote the following function for the circle fit:
function [xc,yc,R]=circfit(x,y)
x=x(:); y=y(:);
a=[x y ones(size(x))]\-(x.^2+y.^2);
xc=-0.5*a(1);
yc=-05*a(2);
R=0.5*sqrt((a(1)^2+a(2)^2)-4*a(3));
end
I read the corners coordinates manually and apply the following code to fit circle
y=C(1050:1100); % C is array of step
x=1050:1100;
[xc,yc,Re] = circfit(x,y);
I got the values of center and radius of circle, which are looking way to higher than I except and I don't understand how to plot this fitted circle. If I plot using
plot((x-xc).^2+(y-yc).^2-Re.^2)
It is same as the corner of the step. Could any one tell me that if approach is correct or not and how to plot fitted curve that I can show it in same way as shown in fig. 2? Is there any other way to find circle fit?  %
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

Darshan Ramakant Bhat el 18 de En. de 2018
This is due to the different scaling of the axes. If you observe y axes varies from 0 to 1, while x axes varies from 0 to 2000. MATLAB automatically fits the aspect ration of the axes for the visualization purpose. You have to limit the x-axes range to view the circle.
Please refer to the below code:
clc;
clear all;
close all;
t = 1 : 2000;
sf = t>1000;
figure(1);
plot(t,sf);
xlim([1000 1002])
c = [1001.05,0.95];
r = 0.05;
hold on;
%Inbuilt function in image processing toolbox to plot the circle.
viscircles(c,r);
##### 2 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Darshan Ramakant Bhat el 19 de En. de 2018
I am not sure what you are trying to do in circfit() function. Can you elaborate on your logic ?

Iniciar sesión para comentar.

Darshan Ramakant Bhat el 19 de En. de 2018
I guess there is something wrong going on in estimating the radius of curvature using the x,y points. Please refer below code to do the same:
Regards,
Darshan
##### 1 comentarioMostrar NingunoOcultar Ninguno
Swati Jain el 22 de En. de 2018
Hi,
This function is giving same result as I got from my function. Thanks!

Iniciar sesión para comentar.

### Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!