3D surface plot of integrated function

조회 수: 3 (최근 30일)
Alyssa Pope
Alyssa Pope 2021년 4월 7일
댓글: Alyssa Pope 2021년 4월 8일
I'm trying to make a 3D plot to visually represent a plot I made in 2D. I've tried using cylinder, but it creates the solid in the wrong direction, over the x or z axis instead of the y-axis. Below is my code that creates the 2D plot. Is there a way to basically create a shell around the y-axis and represent it in 3D? I've tried using mesh but I can't seem to get things set up properly. Any help would be greatly appreciated!
function value = Function
r = [1:1:350];
S = 0.001;
T = 2400;
t = 1;
u = ((r.^2)*S)./(4*T.*t);
syms y
Wu = zeros(size(u));
for i = 1:length(u)
Wu(i) = integral(@(y)exp(-y)./(y),u(i),inf);
end
Q = 2400;
value = Q/(4*pi*T)*Wu;
%Plot
f1 = figure('Color', [1 1 1]);
ax1 = axes('FontSize', 18, 'FontWeight', 'bold');
plot(ax1, r, value);
title('Value v Distance');
xlabel('Distance (m)');
ylabel('Value');
set(gca,'Ydir','reverse');
ax = gca;
ax.FontSize = 13;
grid on;
end

채택된 답변

DGM
DGM 2021년 4월 7일
편집: DGM 2021년 4월 7일
You can use cylinder. You just need to orient it as needed. For orthogonal rotations, that's easy enough.
r = [1:1:350];
S = 0.001;
T = 2400;
t = 1;
u = ((r.^2)*S)./(4*T.*t);
syms y
Wu = zeros(size(u));
for i = 1:length(u)
Wu(i) = integral(@(y)exp(-y)./(y),u(i),inf);
end
Q = 2400;
value = Q/(4*pi*T)*Wu;
clf
if true % <<-- this is just for sake of testing
[X,Y,Z] = cylinder(value);
h=surf(Y,Z,X)
% make it fancy
shading flat
lightangle(-90,30)
h.FaceLighting = 'gouraud';
h.SpecularStrength = 0.5;
h.AmbientStrength = 0.3;
h.DiffuseStrength = 0.9;
else
ax1 = axes('FontSize', 18, 'FontWeight', 'bold');
plot(ax1, r, value);
title('Value v Distance');
xlabel('Distance (m)');
ylabel('Value');
set(gca,'Ydir','reverse');
ax = gca;
ax.FontSize = 13;
grid on;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by