I can't graph multivariable function that contains cos function doens't work

1 回表示 (過去 30 日間)
수정 이
수정 이 2020 年 10 月 28 日
コメント済み: 수정 이 2020 年 10 月 28 日
I'm trying to graph f(x,y)=(e^x )* cos(y)
By using ulframalpha, I found that the graph should look like this.
>> x=[-4*pi:0.1:4*pi];
>> y=[-4*pi:0.1:4*pi];
>> [X,Y]=meshgrid(x,y);
>> Z=exp(X)*cos(Y);
>> surf(X,Y,Z)
My code look like this, and the result keep shows me this, flat plane.
I changed range for several times, but I don't think that range is not problem.
Can you see any problem in my code?
Any help would be aprreciated.

採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 28 日
Z=exp(X).*cos(Y);
Remember that the * operator is matrix multiplication (inner product). Multiplication of corresponding elements requires the .* operator.
  1 件のコメント
수정 이
수정 이 2020 年 10 月 28 日
I appreciate your help. It was a such a trivial mistake but it made whole code doesn't work. Have a nice day :)

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

その他の回答 (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