フィルターのクリア

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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by