Write a user-defined function that plots a circle given the coordinates of the c
ID: 2327074 • Letter: W
Question
Write a user-defined function that plots a circle given the coordinates of the center and a pont on the circle. For rhe function name and arguments, use circlePC(c,p). The input argument c is a two-element vector with the x and y coordinates of the center and the input argument p is a two-element vector with the x and y coordinates of the a point on the circle. This function has no output arguments.Use the function to plot the following two circles (a) Center at x=7.2, y=-2.9, point on the circle at x=-18, y=0.5 (b) Center at x=-0.9, y=-3.3, point on the circle at x=0, y=10
Explanation / Answer
We have two arguments given i.e the center of the circle. We should preserve those co-ordinates. And them we have a point on the perimeter. Using this point and the center, we will find out the radius by finding the distance between them. Then, using center and radius, we can get values of all points using sin and cos theta to find the points on the circle. This is the matlab code. You can turn it into any sort of unction you like.
Matlab code
centerx = input("enter the x-co-ordinate of the center");
centery = input("enter the y-co-ordinate of the center");
pointx = input("enter the x-co-ordinate of the point on the circle");
pointy = input("enter the y-co-ordinate of the point on the circle");
r = sqrt((centerx - pointx)^2 + (centery - pointy)^2);
hold on
th = 0:pi/50:2*pi;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.