Plotting an exponential exp(-x), in 3D?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
How can I remove that big circle on the bottom? I mean y values should start from 1 to 200.
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.
.
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!
.
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!
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.
.
Thank you very much! I was looking where I could accept it, so now I found it and accepted it!🙌😊
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!
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.
Is it possible to revolve it around vertical line x=-25? Currently it revolves around vertical line x=0
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.
.
I am looking for something like this, shown in the picture. Pfofile view in terms of (x, y). Simple and clean graph.

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.
.
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
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)

