How to integrate a surf plot
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Raunak Gupta
am 8 Aug. 2020
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 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!