![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177042/image.png)
複数の円の表示
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shunsuke Kimura
el 7 de Feb. de 2017
Comentada: Shunsuke Kimura
el 8 de Feb. de 2017
中心座標(x, y) と半径r の列 X, Y, R をそれぞれ同じサイズで保存しているとき,それぞれの円をプロットするスクリプトをfor 文を使わずに実装したいです. どのようにすれば良いのでしょうか? ちなみに,for 文を使って所望の動作を実現するには以下のようなスクリプトになります.
figure
hold on
axis equal
t = linspace(0,2*pi,100);
X = [1; 2; 4];
Y = [3; 2; 1];
R = [1; 2; 0.5];
for i = 1:numel(X)
plot(R(i)*sin(t)+X(i),R(i)*cos(t)+Y(i))
end
難しさとしてはt のサイズが X, Y, R と異なること(サイズが同じであっても所望の動作はできません), さらに,kron で無理やり点の集合を作るとすべての点が繋がった状態で表示されてしまうなどの問題を抱えております. 目的としては X, Y, R がある程度大規模なものを作成する予定です. どうぞよろしくお願いいたします.
0 comentarios
Respuesta aceptada
mizuki
el 7 de Feb. de 2017
for の部分を次の1行で置き換える方法ではいかがでしょうか。(for で描いたときと xlim, ylim が少し変わります)
plot( (R*sin(t)+X)', (R*cos(t)+Y)' )
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177042/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!