3D Surface Plot Showing Flat Surface

Hi all,
Completely new to MATLAB but have been asked to produce 3D plot of the function z = x + 2xy² + 3x for x and y values of 0 to 15. I have followed tutorials online showing how to produce a surface plot and entered the attached script but my end result is a flat plane and I've tried it many times. I produced the same graph on excel for comparison and it was completely different (it was actually 3D). Can someone please explain how to solve this in a manner a beginner would understand?
%
>> x=[0:1:15];
>> y=[0:1:15];
>> [xx,yy]=meshgrid(x,y);
>> zz=xx+(2*xx*yy.^2)+3*xx;
>> surf(xx,yy,zz);

1 件のコメント

Rena Berman
Rena Berman 2018 年 3 月 19 日
(Answers Dev) Restored edit

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

 採用された回答

Ahmet Cecen
Ahmet Cecen 2018 年 3 月 11 日

0 投票

You for got a dot somewhere:
x=[0:1:15];
y=[0:1:15];
[xx,yy]=meshgrid(x,y);
zz=xx+(2*xx.*yy.^2)+3*xx; % HERE
surf(xx,yy,zz);

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2018 年 3 月 11 日

編集済み:

2018 年 3 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by