フィルターのクリア

一つの3次元座標軸内に複数の球面をプロットしたい

12 ビュー (過去 30 日間)
kamaboko_tarou
kamaboko_tarou 2024 年 1 月 16 日
コメント済み: Dyuman Joshi 2024 年 1 月 16 日
中心と半径を指定した複数の球面を一つの3次元座標軸内にプロットしたいのですが、画像の様に2次元座標軸内にプロットされてしまいます。
以下、コードです
D = [4.8115220,1.5733090,1.8423250;4.8117520,1.5608190,1.8555420;4.8119040,1.5478110,1.8679730];
figure;
hold on;
for n=1:3
% 中心座標
center = D(n,:);
% 半径
radius = 0.01;
% 球の分割数
num_points = 50;
% sphere関数を使用して球を描く
[x, y, z] = sphere(num_points);
x = x * radius + center(1);
y = y * radius + center(2);
z = z * radius + center(3);
% 描画
surf(x, y, z);
axis equal;
end
xlabel('X軸');
ylabel('Y軸');
zlabel('Z軸');

採用された回答

Dyuman Joshi
Dyuman Joshi 2024 年 1 月 16 日
They are plotted in 3D, you just need to change the line of sight.
Check view for more information.
D = [4.8115220,1.5733090,1.8423250;4.8117520,1.5608190,1.8555420;4.8119040,1.5478110,1.8679730];
figure;
hold on;
%% Bring the constant quantities outside of the loop
% 半径
radius = 0.01;
% 球の分割数
num_points = 50;
for n=1:3
% 中心座標
center = D(n,:);
% sphere関数を使用して球を描く
[x, y, z] = sphere(num_points);
x = x * radius + center(1);
y = y * radius + center(2);
z = z * radius + center(3);
% 描画
surf(x, y, z);
axis equal;
end
xlabel('X軸');
ylabel('Y軸');
zlabel('Z軸');
%% Change the view
view(3)
  2 件のコメント
kamaboko_tarou
kamaboko_tarou 2024 年 1 月 16 日
wow, thank you!!!
Dyuman Joshi
Dyuman Joshi 2024 年 1 月 16 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!