How to find volume under fitted data?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a set of data, fitted by polynomial of 8th order. I want to find the volume under this surface (due to rotation around y axis for example). I am not sure how to do it. Should I use dblquad or trapz? Since dblquad needs function handle and I do not have the function, just the interpolated data (I also can not use interp2 (as suggested in some answers), because it uses linear interpolation. Any idea how I can find the volume?
Thank you!
댓글 수: 3
채택된 답변
Teja Muppirala
2017년 9월 28일
편집: Teja Muppirala
2017년 9월 28일
If you have a function y = f(r), which it sounds like you do since you have a polynomial, then you can use integral.
y = @(r) 1-r; % y can be any arbitrary function of r. Put the function for your curve here (POLYVAL?).
a = 0; % Some limits of integration r = a to b
b = 1;
% Volume under surface of rotation:
vol = 2*pi*integral(@(r) y(r) .* r, a, b) % Put in the extra ".*r" for polar coords.
Here I used y = 1-r, so it is a cone, and I can verify that the answer I got (vol=1.047) was indeed equal to the analytical answer for the volume of a cone with unit height and radius (pi/3).
If you don't have a function, but just some discrete set of values r and y, then you can use INTERP1 along with INTEGRAL.
r = [ 0 0.2 0.4 0.6 0.8 1.0 ]; % Again, just use a unit cone for testing purposes
y = [ 1 0.8 0.6 0.4 0.2 0 ];
Yfun = @(p) interp1(r, y, p);
vol = 2*pi*integral(@(r) Yfun(r).*r, 0, 1) % Again, you'll get 1.0472
댓글 수: 8
Torsten
2017년 9월 29일
편집: Torsten
2017년 9월 29일
Teja is right - sorry for the confusion.
The formula says that the volume of the surface of revolution around the y-axis is obtained by integrating the lateral surface area A(x) of the cylinders which you get when you rotate a vertical line from the x-axis up to your polynomial function around the y-axis ( which is A(x) = 2*pi*x*P(x) ).
Best wishes
Torsten.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!