3D surface plot of integrated function

2 views (last 30 days)
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

Accepted Answer

DGM
DGM on 7 Apr 2021
Edited: DGM on 7 Apr 2021
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

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!