display fix radius circles
3 ビュー (過去 30 日間)
古いコメントを表示
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
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
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
2021 年 8 月 4 日
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
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 Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!