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

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

 采纳的回答

MathWorks Support Team
编辑: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!