display fix radius circles

조회 수: 3 (최근 30일)
Jordan
Jordan 2021년 7월 29일
댓글: dpb 2021년 8월 10일
I wanna to put fix radius circles at (0,1),(1,1),(2,1),(3,1) with diameter of 1 at same time. Is there any way can achieve this?
  댓글 수: 2
dpb
dpb 2021년 7월 29일
Yeah, but MATLAB incredibly doesn't have a graphics circle object nor defined circle-plotting function.
rectangle (of all things!) can draw circles, but is also neutered and defies the documentation in that it won't accept anything that goes to the negative side of an axis so you can't use it to draw the circle on the y-axis at the origin.
You have to define the parametric values or x,y in cartesian coordinates from the r*sin(th), r*cos(th) instead.
I'm sure there are some FEX functions.
But, it is one of those absolute mysteries that are totally unfathomable.
figure
pos = [-1 1 -1 1];
xlim([-10 10]),ylim([-10 10]),axis equal
axis equal
rectangle('Position',pos,'Curvature',[1 1])
Error using rectangle
Width and height must be greater than or equal to 0
>>
>> doc rectangle
says
"pos — Size and location of rectangle
four-element vector of the form [x y w h]
Size and location of the rectangle, specified as a four-element vector of the form [x y w h]. The x and y elements define the coordinate for the lower left corner of the rectangle. The w and h elements define the dimensions of the rectangle.
All values are in data units."
The above are all in data units within the limits of the defined axes but aren't allowed.
dpb
dpb 2021년 8월 10일
function hL = circle(x0,y0,r)
th = 0:pi/100:2*pi;
x = r * cos(th) + x0;
y = r * sin(th) + y0;
hL=plot(x,y);
end
is a most rudimentary illustration of generating the circle cartesian coordinates...

댓글을 달려면 로그인하십시오.

답변 (1개)

Sivani Pentapati
Sivani Pentapati 2021년 8월 4일
As per my knowledge, you can use the viscricles function to plot 4 circles at the same time
Refer to the below code for your usecase:
viscircles([0,1;1,1;2,1;3,1],0.5*ones(4,1))
where you pass in an array, with center co-ordinates, (0,1),(1,1),(2,1),(3,1) as the first argument and radii, 0.5 as the second argument
  댓글 수: 1
dpb
dpb 2021년 8월 9일
NB: visicircles is in Image Processing Toolbox, not base MATLAB.
Which is fine for those who have the TB, not so much if don't.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by