Volume under curve around y-axis with function discontinuity

1 view (last 30 days)
Hi, I'm hoping someone who is both a math and Matlab guru can help me here! I have a function y that was created with uniformly spaced x values. Think of x as the radius of a circle with a maximum value of 25. The spacing used was the variable 'xstep'=0.01. I need to calculate the volume rotated around the y-axis for: 1. A cylinder with height equal to the max value of y (i.e. 1) 2. The area under the curve I believe I am getting correct results if the function did not have a discontinuity at x=20. I think the problem is due to a volume that should be counted at x=20 when rotated around the y axis, but because the y value is discontinuous here it's not being accounted for. The correct real part of the ratio of Volume_Of_Cylinder/Volume_Under_Curve should be about 1.28, but I'm getting 1.71. If anyone can solve this they'd be my hero! :) Note 1: a cylinder volume rotated about the y axis = pi*r^2*h Note 2: a curve volume rotated about the y axis = 2*pi*integral(x*y*dx) Reference: http://www.wyzant.com/resources/lessons/math/calculus/integration/finding_volume
Here are my equations/code and the data sets are attached:
if true
xstep=0.01;
Volume_Of_Cylinder=pi.*max(x).^2.*max(y); % Volume of cylinder rotated around y-axis
Volume_Under_Curve=2.*pi.*(trapz(x.*y.*xstep,2)); % Volume of area under curve rotated around y-axis
VUC_Ratio=VUC1/VUC2; % real part should be about 1.28
end
Thanks!!

Answers (0)

Community Treasure Hunt

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

Start Hunting!