Graphing region of intersection

4 次查看(过去 30 天)
I'm trying to compute the volume of the region between x^2 + y^2 = 1 and x^2 + z^2 = 1. But first I need to draw the cross sections of the region bounded between the two functions in order to get the order of integration, but I'm confused on how to do that.
Here's what I have so far:
r = 1; % radius
n = 200;
[X, Y, Z] = cylinder(r, n);
h = 2; % height
Z = h*Z;
surf(X, Y, Z, 'facecolor', [179/255, 205/255, 227/255], 'LineStyle', 'none')
hold on
fill3(X(2,:), Y(2,:), Z(2,:), [251/255, 180/255, 174/255], 'LineStyle', 'none'); % top
fill3(X(1,:), Y(1,:), Z(1,:), [204/255, 235/255, 197/255], 'LineStyle', 'none'); % bottom
hold off
axis square

采纳的回答

Star Strider
Star Strider 2022-4-23
In your original earlier post the cylinders were described differently.
Using that definition, I would do something like this (with slightly edited code to plot two distinct concentric cylinders) —
syms x1 y1 x2 y2
x2 = 0.8*x1; % Change As Necessary To Get The Correct Dimensions
y2 = 0.8*y2; % Change As Necessary To Get The Correct Dimensions
cyl = x1^2 + y1^2 - 1;
cyl2 = x2^2 + y2^2 - 1;
figure
hfi1 = fimplicit(cyl);
xv1 = hfi1.XData;
yv1 = hfi1.YData;
hold on
hfi2 = fimplicit(cyl2);
xv2 = hfi2.XData;
yv2 = hfi2.YData;
hold off
axis('equal')
legend('cyl','cyl_2', 'Location','bestoutside')
figure
surf([xv1; xv1], [yv1; yv1], [zeros(size(yv1)); ones(size(yv1))], 'EdgeColor','interp')
hold on
surf([xv2; xv2], [yv2; yv2], [zeros(size(yv2)); ones(size(yv2))], 'EdgeColor','interp')
hold off
grid on
axis('equal')
colormap(turbo)
Make appropriate changes to get the desired results.
.
  9 个评论
Ikenna Iwudike
Ikenna Iwudike 2022-4-24
This is the way I did it.
syms x y z
f = x^2 + y^2 ==1;
g = x^2 + z^2 ==1;
zbounds = solve(g,z);
ybounds = solve(f,y);
Firststep = int(int(1,z,zbounds(2),zbounds(1)),y,ybounds(2),ybounds(1));
>> int(Firststep,x,-1,1)
Star Strider
Star Strider 2022-4-24
Thank you.
I was trying to follow it to see if I could reproduce it.
syms x y z
f = x^2 + y^2 ==1;
g = x^2 + z^2 ==1;
zbounds = solve(g,z)
zbounds = 
ybounds = solve(f,y)
ybounds = 
Firststep = int(int(1,z,zbounds(2),zbounds(1)),y,ybounds(2),ybounds(1))
Firststep = 
Volume = int(Firststep,x,-1,1)
Volume = 
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by