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

32 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 14 Apr. 2010
2次元上に円を描画する方法を教えてください。

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 13 Nov. 2024
Bearbeitet: MathWorks Support Team am 13 Nov. 2024
関数としては提供されていませんが、円を構成する点を求め、それらを結ぶことで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

Weitere Antworten (0)

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!