3D surface plot of integrated function

1 vue (au cours des 30 derniers jours)
Alyssa Pope
Alyssa Pope le 7 Avr 2021
Commenté : Alyssa Pope le 8 Avr 2021
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

Réponse acceptée

DGM
DGM le 7 Avr 2021
Modifié(e) : DGM le 7 Avr 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
  1 commentaire
Alyssa Pope
Alyssa Pope le 8 Avr 2021
That's it!! Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by