2次元上に円を描画し​たいのですが、どのよ​うにすればよいですか​?

2次元上に円を描画する方法を教えてください。

 採用された回答

MathWorks Support Team
MathWorks Support Team 2024 年 11 月 13 日
編集済み: MathWorks Support Team 2024 年 11 月 13 日

0 投票

関数としては提供されていませんが、円を構成する点を求め、それらを結ぶことで2次元上に円を描画することができます。
% 等間隔ベクトルの作成 t = linspace(0,2*pi,100); figure plot(sin(t),cos(t)) axis([-2,2,-2,2]) axis square
また、円の中心や半径を指定することもできます。
figure cx = 1; cy = 1; % 中心 r = 0.5; % 半径 plot(r*sin(t)+cx,r*cos(t)+cy) axis([-2,2,-2,2]) axis square
その他に、patch関数やcylinder関数を使用しても描画することができます。
% patchを使う方法 figure patch(sin(t),cos(t),'k') axis([-2,2,-2,2]) axis square % cylinderを使う方法 figure [x,y,z] = cylinder(1,100); z(:) = 0; % 高さデータを0に設定 surf(x,y,z) view(2) axis([-2,2,-2,2]) axis square grid off

その他の回答 (0 件)

カテゴリ

製品

タグ

Community Treasure Hunt

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

Start Hunting!