In Matlab is there any special function to draw arc with user defined radius, points and angle. If it is not there how is it possible to draw a curve in a figure using user defined radius,angles, points etc. Thank you

 採用された回答

Star Strider
Star Strider 2016 年 3 月 27 日

8 投票

There are no such functions in core MATLAB, but they’re easy enough to write.
This code plots an arc of stars:
circr = @(radius,rad_ang) [radius*cos(rad_ang); radius*sin(rad_ang)]; % Circle Function For Angles In Radians
circd = @(radius,deg_ang) [radius*cosd(deg_ang); radius*sind(deg_ang)]; % Circle Function For Angles In Degrees
N = 25; % Number Of Points In Complete Circle
r_angl = linspace(pi/4, 3*pi/4, N); % Angle Defining Arc Segment (radians)
radius = 1.5; % Arc Radius
xy_r = circr(radius,r_angl); % Matrix (2xN) Of (x,y) Coordinates
figure(1)
plot(xy_r(1,:), xy_r(2,:), 'bp') % Draw An Arc Of Blue Stars
axis([-1.25*radius 1.25*radius 0 1.25*radius]) % Set Axis Limits
axis equal % No Distortion With ‘axis equal’

9 件のコメント

rupam baruah
rupam baruah 2016 年 3 月 28 日
Thanks a Lot. Can u calculate the length of the arc in Pixel unit?
Star Strider
Star Strider 2016 年 3 月 28 日
My pleasure.
Calculating the length of the arc mathematically is straightforward.
Calculating it in pixels depends on a number of characteristics of the image. Perhaps the regionprops function will do what you want. Experiment with it.
kei mcqueen
kei mcqueen 2018 年 7 月 11 日
Hello thank you for your awesome code, it has helped me with a problem I was having. Is it possible to modify the origin point of the arc? When I try modifying it myself it keeps the origin at 0,0. Thank You.
Star Strider
Star Strider 2018 年 7 月 11 日
My pleasure.
Add the origin as a third argument:
circr = @(radius,rad_ang,p0) [radius*cos(rad_ang)+p0(1); radius*sin(rad_ang)+p0(2)]; % Circle Function For Angles In Radians
Here, ‘p0(1)’ is the x-coordinate of the origin, ‘p0(2)’ is the y-coordinate. Change ‘circd’ similarly.
A vote for my Answer would be appreciated!
Ram W
Ram W 2019 年 5 月 17 日
sorry, I have a qestion regarding your last comment, how can I modiy the origin with 3 coordinates (x,y,z) ?
Amal Fennich
Amal Fennich 2020 年 3 月 17 日
r_angl = linspace(pi/4, 3*pi/4, N);
what does this meanis beacause I have an angle of 3.433 degree and I do not know haow to implement it here ! any help ?
Sean Brennan
Sean Brennan 2020 年 3 月 31 日
In this line, linspace produces a vector of N points, equally spaced (linearly - hence the name), starting from pi/4 to 3pi/4.
If you have an angle of 3.433 degrees to start, and say 90 degrees to end, and you wanted 100 points between these start and end angles, then your command would be
r_angl = linspace(3.433*pi/180, 90*pi/180,100)
Hope this helps!
Audrey Fernandes
Audrey Fernandes 2020 年 7 月 16 日
How can this arc be repeated into a series of arcs? Like the one this the image below?
Matheus Sousa
Matheus Sousa 2021 年 3 月 26 日
Adding the center points of each circle to xy_r should do it, in the example abova nothing was added so the center is in [0,0], but if you add 3 on xy_r(1,:) and 0 to xy_r(2,:) the position of the arc will change as well.

サインインしてコメントする。

その他の回答 (2 件)

Ade Ade
Ade Ade 2019 年 7 月 9 日

0 投票

%Equation of a circle with centre (a,b) is (x-a)^2+ (y-b)^2 = r^2
%Circle Centre (1,1), radius = 10
k=1; %counter
c =1 ; % value of x at the centre of the circle
while c <=11
x(k) = c ;
vv = (c-1)^2 ;
y (k) = 1 + real (sqrt (100 - vv) );
c= c + 0.02;
k=k+1;
end
plot (x, y, 'r')
axis equal
arc.jpg
Sudhir S
Sudhir S 2022 年 4 月 28 日

0 投票

Hello everyone, I'm currently working on a project that requires MATLAB code. This is a 2D blade profile which was design using CATIA V5. I was able to code up till this point, but I got stuck on the arc creation. The radius of the arc is given, and the beginning point is fixed for that arc. The inlet angle is used to determine the finishing point. Could someone assist me in locating a solution?

質問済み:

2016 年 3 月 27 日

回答済み:

2022 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by