I have made a matlab function, but when I use this function in a program, it is not giving all the outputs (xc,yc,R). Rather it is giving only xc!
This is a function which fits a semicircle on a set of data points. I have a file A having two columns (X and Y). I take x=A(:1) and y=A(:,2). Then using the following function on a program, I suppose to get xc, yc and R. But unfortunately, I am getting only xc!
function [xc,yc,R] = semicircle( x,y ) %To Fit a semicircle on a distribution % Detailed explanation goes here a=[x y ones(size(x),1)]\[-(x.^2+y.^2)]; %vector of parameter xc = -a(1)/2; yc = -a(2)/2; R = sqrt(a(1)^2/4+a(2)^2/4-a(3)); % display original data figure,plot(x,y,'o'); %original data theta=linspace(0,-pi,1000); %generate 1000 angle points, you can change the range of angle xx=xc+R*cos(theta); yy=yc+R*sin(theta); hold on; plot(xx,yy,'r') end