필터 지우기
필터 지우기

Straight Lines inside Circles

조회 수: 3 (최근 30일)
premraj
premraj 2011년 9월 19일
Hi,
How to draw 10 straight lines horizontally and 10 vertically inside a circlular shape.
Please note that the lines are equally spaced.
Thanks in advance.
Prem

답변 (3개)

Walter Roberson
Walter Roberson 2011년 9월 19일
Hint:
linspace(-Radius, Radius, 10+2)
and then throw away the first and last of those results.
  댓글 수: 1
premraj
premraj 2011년 9월 20일
thanks..i tried to create the grids with ur hint.But failed to draw inside the circle.

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


premraj
premraj 2011년 9월 20일
I could draw the grid lines with specified X/Y line numbers.But don't know how to restrict the lines inside the circle only.
Radius =150;
xGridLineNumbers=10;
yGridLineNumbers=10;
xmin=-Radius ;
ymin=-Radius ;
xmax=Radius ;
ymax=Radius ;
color=[0 0 0]
x = linspace ( xmin, xmax, xGridLineNumbers);
y = linspace ( ymin, ymax, yGridLineNumbers);
for i = 1 : xGridLineNumbers
line ( [ x(i), x(i) ], [ ymin, ymax ],'Color', 'color');
end
for i = 1 : yGridLineNumbers
line ( [ xmin, xmax ], [ y(i), y(i) ],'Color', 'color');
end

premraj
premraj 2011년 9월 20일
I got a simple work around!!! function is given below.
xGridLines is the no of X axis grids required.
yGridLines is the no of Y axis grids required.
Radius is the given radius of the circle.
function DrawGridLinesWithRadius(xGridLines,yGridLines,Radius )
horzSample=2*Radius/xGridLines;
vertSample=2*Radius/yGridLines;
for i = 1 : xGridLines-1 % for Horizontal lines
y=(-Radius)+(horzSample*i);
xmax=sqrt(Radius^2-(y)^2);
xmin=-xmax;
line ([ xmin, xmax ],[ y, y ],'Color',[0 0 0]);
end
for i = 1 : yGridLines-1 % for Vertical lines
x=(-Radius)+(vertSample*i);
ymax=sqrt(Radius^2-(x)^2);
ymin=-ymax;
line ([ x, x ],[ ymin, ymax ],'Color',[0 0 0]);
end
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by