フィルターのクリア

Plotting y=sin x in 3d

25 ビュー (過去 30 日間)
Amril Luqman
Amril Luqman 2021 年 5 月 8 日
コメント済み: Amril Luqman 2021 年 5 月 8 日
I want to plot y=sin x,0≤ x ≤ 2π, with 300 linear space points interval in 3D. Im kinda new to matlab, so i the read help center to learn how to do plot 3d graph. Can someone help me check it if it correct or not?
x=linspace(0,2*pi,300);
[x,y]=mehsgrid(x);
z=sin(x);
surf(x,y,z)

採用された回答

DGM
DGM 2021 年 5 月 8 日
What did you get when you ran it? Whether it's "right" depends on what the goal is.
% this plots the surface over both x and y
% z is invariant over y
x = linspace(0,2*pi,300);
[x,y]=meshgrid(x); % spelled right
z = sin(x);
surf(x,y,z)
% this plots z for y=0
x = linspace(0,2*pi,300);
y = zeros(size(x));
z = sin(x);
plot3(x,y,z)
Depends what you want.
  1 件のコメント
Amril Luqman
Amril Luqman 2021 年 5 月 8 日
Ohh.. i want the graph to looks like the second one. Thank you very much for the help!!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by