Question on how to use scatter3

2 ビュー (過去 30 日間)
Oliver Ferenczi
Oliver Ferenczi 2019 年 11 月 15 日
コメント済み: Star Strider 2019 年 11 月 15 日
Hi, I trying to use the function scatter3,
I was able to plot a 2D scatter graph using just X and Y, however I want to make it 3D to allow the user to look around the graph.
Below is my code.
X = linspace(0,time,50);
Y = height-(9.81/2)*(trajectory.^2);
Z = 0;
scatter3(app.UIAxes,X,Y,Z,'ro');
Im not sure what the Z value should be in order to do this, however when I run the program, it gives me the error,
"X, Y and Z must be vectors of the same length."
Any ideas on how to make the 2D graph 3D?
Thanks!

採用された回答

Star Strider
Star Strider 2019 年 11 月 15 日
The ‘Z’ vector can be anything, providing it is a vector of the same size as the others. Setting it equal to:
Z = zeros(size(X));
will simply create a 2D plot in 3D coordinates. A much better approach would be to set:
Z = X;
if you want to clearly delineate the points.
  2 件のコメント
Oliver Ferenczi
Oliver Ferenczi 2019 年 11 月 15 日
Thanks!
Star Strider
Star Strider 2019 年 11 月 15 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by