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
- Plot the following MATLAB functions: y = 3x+2 with x = 0, 0.25, 0.5, ...., 7.75, 8
- MATLAB function that takes a matrix as argument and then ask from the user
- MATLAB program which computes the mean and standard deviation of the data. Use FOR LOOPs.
- Plot the following MATLAB functions y = ln(exp(x^-1)) with x = 1, 1.5, 2, ..., 4
- Plot the following MATLAB functions: y = exp(-x^2) with x = 0, 0.1, 0.2, ..., 2
Share this post
0 comments: