3D surface plot of integrated function

1 回表示 (過去 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
  1 件のコメント
Alyssa Pope
Alyssa Pope 2021 年 4 月 8 日
That's it!! Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by