フィルターのクリア

Slice of a 3D plot and projection of that function in a plane.

20 ビュー (過去 30 日間)
U B
U B 2024 年 9 月 5 日 16:01
コメント済み: Star Strider 2024 年 9 月 5 日 16:26
I'm trying to plot the mesh-plot of a Gaussian beam and slice through the centre. With it I'm tring to project the 3D plot on a plane together too. I'm using-
x = linspace(-2,2,100); y = linspace(0,2,100);
[X,Y] = meshgrid(x,y);
Rho2 = X.*X + Y.*Y;
Z = exp(-Rho2);
figure,
mesh(X,Y,Z,'FaceAlpha',1); hold on
contourf(X,Y,Z,70,'edgecolor','none'),colormap cool
But now the 2D Gaussing is also cut at the centre. Is there any way I can get the sliced 3D Gaussin and full 2D Gaussian together.
I appreciate your help.

採用された回答

Matt J
Matt J 2024 年 9 月 5 日 16:12
編集済み: Matt J 2024 年 9 月 5 日 16:18
[x,y,yhalf]=deal(linspace(-2,2,100));
yhalf(y<0)=nan;
Z = exp(-( x.^2 + y.^2'));
figure,
mesh(x,yhalf,Z,'FaceAlpha',1); hold on
contourf(x,y,Z,70,'edgecolor','none'),colormap cool

その他の回答 (1 件)

Star Strider
Star Strider 2024 年 9 月 5 日 16:13
II’m not certain what result you want.
Try this —
x = linspace(-2,2,100); y = linspace(0,2,100);
[X,Y] = meshgrid(x,y);
Rho2 = X.*X + Y.*Y;
Z = exp(-Rho2);
x2 = linspace(-2,2,100);
y2 = linspace(-2,2,100);
[X2,Y2] = meshgrid(x2,y2);
Rho22 = X2.*X2 + Y2.*Y2;
Z2 = exp(-(X.^2 + Y2.^2));
figure,
mesh(X,Y,Z,'FaceAlpha',1); hold on
contourf(X2,Y2,Z2,70,'edgecolor','none'),colormap cool
The approach here iis to define ‘y2’ over the full extent, and then recalculate ‘Z2’ using a slightly different function, and then reecalculate the contourf plot using them.
.
  2 件のコメント
U B
U B 2024 年 9 月 5 日 16:24
Oh just by chnaging the axis we can get it. Thank you so much.
Star Strider
Star Strider 2024 年 9 月 5 日 16:26
My pleasure!

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

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by