フィルターのクリア

Meshing of a surface plot?

1 回表示 (過去 30 日間)
Matt Amador
Matt Amador 2017 年 11 月 16 日
コメント済み: Star Strider 2017 年 11 月 16 日
Hello there. I have a bit of trouble with my code. It's supposed to 3D plot with the mesh, and surface plot command the following equation: e^(x+i*y) with the intervals -1 > x >1 and -2pi > y > 2pi. I keep getting an error that the matrix dimensions must agree, but I don't know why that is occurring. Can someone help?
x = -1:.1:1;
y = -2*pi:.1:2*pi;
z = exp(x+i.*y);
[Xm, Ym] = meshgrid(x,y);
surf(x,y,z)

回答 (1 件)

Star Strider
Star Strider 2017 年 11 月 16 日
Calculate ‘z’ After defining ‘Xm’ and ‘Ym’, and use those as the arguments:
x = -1:.1:1;
y = -2*pi:.1:2*pi;
z = @(x,y) exp(x+i.*y); % Create Anonymous Function For Ceonvenience
[Xm, Ym] = meshgrid(x,y);
surf(x,y, abs(z(Xm,Ym)))
You didn’t define ‘i’ so both MATLAB and I believe you want the imaginary operator. The plots will not render the imaginary values, so here I used the abs function to plot the magnitude.
  2 件のコメント
Matt Amador
Matt Amador 2017 年 11 月 16 日
Oh, I just remembered about the imaginary operator. Thanks for that. Also, would it be possible to have a contour plot in this as well?
Star Strider
Star Strider 2017 年 11 月 16 日
My pleasure.
You can either create a separate plot with the contour or contourf functions, or add a contour plot below the surf plot by using the surfc function. (The meshc function adds a contour plot to mesh plots.)

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by