hi..Im new in matlab programming. Can someone help me plot 3D graph of y=x-x^2, where z is form negative infinity to infinity.

2 ビュー (過去 30 日間)
x=linspace(-0.5,0.5);
y=linspace(-0.5,0.5);
y=x-x.^2;
plot(x,y)
i have done this,but how to plot it into 3D where it will be plane?
  3 件のコメント
Ameer Hamza
Ameer Hamza 2018 年 6 月 26 日
What is z in your equation? What is your idea of plotting to infinity on a finite plane?
AHMAD AKMAL
AHMAD AKMAL 2018 年 6 月 26 日
z is undetermine, i just want to fine a plane of function y=x-x^2 in 3D, let take z is from -10 to 10.

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

回答 (1 件)

Ameer Hamza
Ameer Hamza 2018 年 6 月 26 日
If you want to plot something the 3d surface plot of this equation
z = y - x + x^2
then try
x = linspace(-0.5, 0.5);
y = linspace(-0.5, 0.5);
[X, Y] = meshgrid(x, y);
Z = Y - X + X.^2;
mesh(X,Y,Z)
  2 件のコメント
AHMAD AKMAL
AHMAD AKMAL 2018 年 6 月 26 日
this is not what i mean, to understand my question further, for example, function x^2+y^2 is circle in 2D but in 3D it will be cylinder if the funtion of z=x^2+y^2 and the value of z is fixed , but if we take z=x^2+y^2 where z=0,1,2,3,..., it will be bowl shape in 3D. i want to highlight the cylinder shape. i want to get a plane as in this example of cyclinder that i stated above. pls help me
Ameer Hamza
Ameer Hamza 2018 年 6 月 26 日
If you just want to extend the 2D shape in third dimension then use
x = linspace(-0.5, 0.5);
z = -10:10;
[X, Z] = meshgrid(x, z);
Y = X - X.^2;
surf(X, Y, Z)

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

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by