Plotting an exponential exp(-x), in 3D?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, I want to plot exp(-x) which is e^-x, and revolve it around x=-5 in order to get a 3D solid that looks like a cooling tower of nuclear power plants. However the limit of y values should be from 1 to 200 which the height of the tower. How can I do that? 

Thanks!
採用された回答
Star Strider
2020 年 6 月 14 日
Try this:
r = linspace(0.5, 5, 50);
a = linspace(0, 2*pi, 60);
[R,A] = ndgrid(r,a);
Z = exp(-R);
[X,Y,Z] = pol2cart(A,R,Z);
figure
mesh(X, Y, Z)
grid on
producing:

.Experiment to get it to look the way you want it to look.
16 件のコメント
Ibrokhimbek Odinaev
2020 年 6 月 14 日
How can I remove that big circle on the bottom? I mean y values should start from 1 to 200.
Star Strider
2020 年 6 月 14 日
Try this slightly revised version:
sval = 2.5; % Shape Factor
hval = 800; % Height Factor
inner_rad = 0.5; % Inner Radius (Top)
outer_rad = 1.1; % Outer Radius (Base)
r = linspace(inner_rad, outer_rad, 50);
a = linspace(0, 2*pi, 60);
[R,A] = ndgrid(r,a);
Z = hval*exp(-R*sval);
[X,Y,Z] = pol2cart(A,R,Z);
figure
mesh(X, Y, Z)
grid on
Change ‘sval’ and ‘hval’ and the other parameters to get the result you want.
.
Ibrokhimbek Odinaev
2020 年 6 月 15 日
Thank you very much! This is what I need. Appreciate it!🙌
Star Strider
2020 年 6 月 15 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Ibrokhimbek Odinaev
2020 年 6 月 18 日
I was wondering if you could put comments for each line of code, so then I would be able to explain this code during the presentation. Thank you!
Star Strider
2020 年 6 月 18 日
I am not certain what you want.
This is the best I can do:
sval = 2.5; % Shape Factor (Determines Vertical Curvature)
hval = 800; % Height Factor (Determines Maximum Vertical Height)
inner_rad = 0.5; % Inner Radius (Top)
outer_rad = 1.1; % Outer Radius (Base)
r = linspace(inner_rad, outer_rad, 50); % Define Radius (Vector)
a = linspace(0, 2*pi, 60); % Define Angle In Radians (Vector)
[R,A] = ndgrid(r,a); % Create Matrices For 3D Plot From Radius Vector & Angle Vector
Z = hval*exp(-R*sval); % Calculate Cooling Tower Shape (Matrix)
[X,Y,Z] = pol2cart(A,R,Z); % Convert Polar Matrices To Cartesian Matrices For 3D Plot
figure % Create Figure Window
mesh(X, Y, Z) % Create ‘mesh’ Plot Of 3D Cooling Tower
grid on % Create Grid Lines On All Axes
I would appreciate it if you would Accept my Answer.
.
Ibrokhimbek Odinaev
2020 年 6 月 19 日
Thank you very much! I was looking where I could accept it, so now I found it and accepted it!🙌😊
Ibrokhimbek Odinaev
2020 年 6 月 19 日
One more question. If you don't mind, could you please plot 2D graph of it as shown in the picture that I uploaded along with the original question. Thank you!
Ibrokhimbek Odinaev
2020 年 6 月 19 日

Star Strider
2020 年 6 月 19 日
Thank you!
The easiest way to do that is to simply rotate the mesh plot:
figure % Create Figure Window
mesh(X, Y, Z) % Create ‘mesh’ Plot Of 3D Cooling Tower
grid on % Create Grid Lines On All Axes
view(90,0)
That is likely as close as it is possible to get.
Ibrokhimbek Odinaev
2020 年 6 月 19 日
Is it possible to revolve it around vertical line x=-25? Currently it revolves around vertical line x=0
Star Strider
2020 年 6 月 19 日
view(90,25)
In the figure GUI, in the Tools drop-down menu, click on Rotate 3D. You can then use the mouse to rotate the figure until you get it the way you want it. The azimuth and elevation appear in the lower left corner of the figure GUI as you do this. Copy those as arguments to the view function to define those as your preferred view.
.
Ibrokhimbek Odinaev
2020 年 6 月 19 日
I am looking for something like this, shown in the picture. Pfofile view in terms of (x, y). Simple and clean graph.

Star Strider
2020 年 6 月 19 日
Try this:
figure % Create Figure Window
mesh(X, Y, Z, 'FaceAlpha',0.2) % Create ‘mesh’ Plot Of 3D Cooling Tower
hold on % More Plots On Same Axes: On
zlvl = [100; 150; 200]; % Z-Levels For Disks
for k = 1:numel(zlvl)
zht = find(hval*exp(-r*sval)<=zlvl(k),1,'first'); % Z-Level Closest Index
patch(X(zht,:), Y(zht,:), Z(zht,:), 'r') % Draw Disk
end
plot3(X(1,:), Y(1,:), Z(1,:), 'k') % Top Circle
plot3(X(end,:), Y(end,:), Z(end,:), 'k') % Base Circle
hold off % More Plots On Same Axes: Off
grid on % Create Grid Lines On All Axes
view(90,10) % Define Camera Position
Experiment to get the result you want.
.
Ibrokhimbek Odinaev
2020 年 6 月 19 日
Perfect! Thank you very much!🙌
Star Strider
2020 年 6 月 19 日
As always, my pleasure!
その他の回答 (1 件)
Ameer Hamza
2020 年 6 月 14 日
exp(-x) does not seem to be a good function for this. Try following code
[X, Y] = meshgrid(-1:0.01:1);
XY = sqrt(X.^2 + Y.^2);
Z = 1./XY;
surf(X, Y, Z)
zlim([0 10])
caxis([0 10])
shading interp

1 件のコメント
Ibrokhimbek Odinaev
2020 年 6 月 14 日
I am doing a project, I have to use exp(-x), plus there shouldn't be th down surface it should be just a solid. Is there any other options?
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
