How to plot a circle?

Hi Everybody,
I am trying to plot a circle with radius= 190 km, and the centre of circle is (2.55, 101.46)both are in degree. If I have to change in km also are become like this (283.87, 11295.0345)km. The question is how can I determine the centre of circle by symbol? and the sketch has been attached here would be useful because I do not know how to plot like this? Could you please help me?
radius = 190;
centerX = 2.55;
centerY = 101.46;
rectangle('Position',[centerX, centerY, radius, radius],...
'Curvature',[1,1],...
'FaceColor','w');
axis square;

2 个评论

I don't know which of the four "download" words to click on on that page. Why don't you try http://snag.gy or tinypic.com?
Thank you. I did it. http://snag.gy/N2jVI.jpg

请先登录,再进行评论。

 采纳的回答

Image Analyst
Image Analyst 2013-1-8

1 个投票

I don't know what "determine the centre of circle by symbol" means, but I can tell you from the code that the center of the circle is at (x, y)=(2.55, 101.46) but I don't know what you mean when you say "both are by degree". What does a pair of degrees mean? Aren't x and y in km? How are they in degrees? What does that mean?

13 个评论

Please look at the sketch. It would help to have a better view. I wonder to know how can I plot it in Matlab?
Are you trying to fit the perimeter of the circle through the centers of those little red ellipses? If so, please refer to the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F
Thank you. I have the code for that tiny red circles and the code "circfit.m" based on the link you sent me suppose to plot a circle around this code. The problem is I do not know how to match all and then run it? As I know I have to save "circfit.m" in the same path as my code, right? Could you please guide me?
Image Analyst
Image Analyst 2013-1-9
编辑:Image Analyst 2013-1-9
Maybe. But you haven't provided to plot the tiny little red circles. But I don't see where the difficulty lies. You know the centers of the little circles, don't you? And I presume you used the code in your initial question to plot it right? So you just put those centers in to the code in the FAQ, and you get the center and radius of the circle which has its perimeter go through the center of your little red circles. It's trivial. But OK, give me the centers of the little red circles and I'll put it into the FAQ code for you if you're unable to.
I know the position of each tiny circle. Yes I used the code in my initial question. I try to put the center and value to the FAQ code but get me error. So please I need your help?
  1. 103.3283737 -1.737315374
  2. 105.0218884 1.859952908
  3. 103.3256787 -1.731133997
  4. 104.614639 -1.186835546
  5. 103.7117851 -1.506892036
  6. 103.3055487 4.91010298
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
xy = [...
103.3283737 -1.737315374
105.0218884 1.859952908
103.3256787 -1.731133997
104.614639 -1.186835546
103.7117851 -1.506892036
103.3055487 4.91010298]
x = xy(:, 1);
y = xy(:,2);
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R. A is an optional
% output describing the circle's equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0
n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
xc = -.5*a(1)
yc = -.5*a(2)
R = sqrt((a(1)^2+a(2)^2)/4-a(3))
In the command window:
xc =
101.536580840907
yc =
1.48302327061266
R =
3.75388783621146
I just plugged your coordinates into the FAQ. What did you do differently to cause it to throw an error? What is the error?
Thanks I get it. Now I faced this error. When I changed the xc, yc and R with the initial code just draw me a big circle without the tiny one.
??? Error: File: circlesbig.m Line: 34 Column: 5 Expression or statement is incomplete or incorrect.
You did not share line 34 but I'm sure that's one you can figure out yourself because you already know how to plot circles. Big, small, whatever - it doesn't matter - it's all the same code. It looks like just a simple syntax error anyway.
Ara
Ara 2013-1-9
编辑:Ara 2013-1-9
Sorry I did not explain it clearly. Yes, its simple error. Now I plot a circle with the centre and radius the code gave me. I still not able to plot tiny circles in the big circle. I guess, I need to play around with plot. If you do not mind I will get back to you.
But you already showed how the rectangle function can be used to plot circles. Just change the center and radius.
Yes,agree. But you know I do not want fit the circle with the positions I gave. What I want a circles that already known radius and centre and now just want to plot and fit the tiny circles in it. I mean fit tiny circles with the constant circles around them. To see weather all the tiny circles located in this area or not.
Thank you, Image. Sorry for the late response. Just remain some questions and I am trying to solve it, if I can't fix it I will bother you again.
Then perhaps you want this: http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects? It will find the smallest circle (or rectangle or triangle, or other redefined shapes) that will contain (fit) all your points inside.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Polar Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by