How to integrate a surf plot
조회 수: 38 (최근 30일)
이전 댓글 표시
Hello, everyone,
i would like to integrate the values over a very specific square area of my surf plot to determine the volume of this area.
Does anyone have any idea how I can do that? I have scanned and obtained a matrix with 256x256 Z-values. Using surf, Matlab automatically creates the 3D plot from the z-values and assigns X and Y to the values 1-256 . Afterwards I subtracted the surfaces from each other. Now I would like to determine the volume of the surface in the middle (look at the top view picture).
I have tried it with intergal2:
Code:
I = integral2(Subtraction(85:185, 85:185), 'all')
Subtraction is the matrix of the subtracted areas, 85:185 is to indicate the X or Y area in which the integral is to be formed and with "all" I tried to tell Matlab to form the integral over the whole area.
I get the following error message:
Error using integral2 (line 67)
Not enough input arguments.
Error in program (line 39)
Integral = integral2(subtraction)
I also used trapz, but if I do this I get a vector 1x101 and not a single value
I = trapz(Subtraction(85:185, 85:185))
댓글 수: 0
답변 (1개)
Raunak Gupta
2020년 8월 8일
Hi,
From the question I think this example clearly explain the steps of doing surface integral. You need to define the ranges in x and y coordinates also with the spacing between each value (I think the ranges are already figured out and spacing is 1 unit). Below example code might be helpful.
x = 85:185;
y = 85:185;
I = trapz(y,trapz(x,Subtraction(85:185, 85:185),2));
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!