Hi, How can i plot a circle of radius 1 and Explain the code fully please if you do not mind

조회 수: 2 (최근 30일)
Hi, How can i plot a circle of radius 1 and Explain the code fully please if you do not mind

답변 (3개)

Star Strider
Star Strider 2016년 2월 11일
t = linspace(0, 2*pi);
x = cos(t);
y = sin(t);
Then plot ‘y’ as a function of ‘x’.
To make it look like a circle in your plot, see the documentation on the axis function.

Waleed Alrabghi
Waleed Alrabghi 2016년 2월 11일
Could you please emphasize more Mr.star.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 2월 11일
axis equal
Or
set(gca, 'DataAspectRatio', [1 1 1])
The default is that X and Y are on different scales, which has the effect of making circles look like ellipses when they are plotted.
Star Strider
Star Strider 2016년 2월 11일
The calculations are basic analytic geometry. Around a circle, the x-coordinate is cos(angle) and the y-coordinate is sin(angle). Then all you do is plot the corresponding x and y points in each vector, and your circle magickally appears! (It will actually look like a circle rather than an ellipse if you follow Walter Roberson’s advise, and my hint.) The angle vector, ‘t’ in my code, is a ‘parameter’, and ‘x’ and ‘y’ are the resulting parametric equations for the circle.
I demonstrated plotting in my Answer to your earlier Question, so I will not repeat that here.

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


Walter Roberson
Walter Roberson 2016년 2월 11일

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by