matlab program which takes coordinates (x, y) of a center of a circle and its radius r from user
Posted in matlab
No comments
Wednesday, July 30, 2014 By Anonymous
Write
a matlab program which takes coordinates (x,
y) of a center of a circle and its radius r from user, program will determine whether any point z with some coordinates lies inside
the circle, on the circle or outside the circle.
Solution:
function
[x,y,r]= QUESTION1(x,y,r) %Function
Take X,Y and Radius as arguments
x1=input('ENTER
COR OF X: '); %COR of X
as Input from user
y1=input('ENTER
COR OF Y: '); %COR of Y
as Input From user
d=sqrt(x1-x)*(x1-x)+(y1-y)*(y1-y); %Calculate the Distance
if(d==r) %Check
the ON CIRCLE Condition
disp('ON CIRCLE');
else
if(d>r) %Chech
the OUTSIDE CIRCLE Condition
disp('OUTSIDE');
else
disp('INSIDE'); %Check the INSIDE Condition
end %END
else if
end %END if
Related posts
Share this post
0 comments: