MATLAB Help Needed: Find Volume Under Surf/Contour Plot

  • Thread starter Lebak
  • Start date
  • Tags
    Matlab
In summary, the conversation is about someone needing help finding the volume underneath a surf or contour plot that represents a sandbox with different heights of sand at different points. They have created the plot using an xls spreadsheet containing values from 50 mm to 950 mm with 50 mm spacing in both x and y directions. They have also calculated the height at different locations using the contourm function and labeled the contours using the clabel function. However, they are now unsure of how to find the volume of sand in the sandbox using the width, length, and height values. The solution is to integrate the values using the rectangle method of calculus or more advanced methods like the trapezoidal rule or Simpson's rule. This can be done in Excel
  • #1
Lebak
1
0
I need help finding the volume underneath this surf plot. Or contour plot. We have a project including a sandbox with different heights of sand at different points. So create the plot I have used

x = [50:50:950];
y = [50:50:950];
z = 'values from an xls spreadsheet. Containing every height value with 50mm spacing from 50 mm to 950 mm in both x and y directions'.

[c,h] = contourm(x,y,z)
ht=clabel(c,h);
That's all I've done so far, I need to find the volume of sand in our sand box, and I know the width and length of it and also the height at those different locations.

Please help, I'm completely lost!
 
Physics news on Phys.org
  • #2
You should "integrate" the values just as you would in calculus. Since you have discrete values in your spreadsheet, sum them together and multiply by the grid cell area, according to the rectangle method of calculus. (You can be fancy and use the trapezoidal rule or Simpson's rule, but you probably don't need the extra accuracy.) You can do this in Excel.
 

FAQ: MATLAB Help Needed: Find Volume Under Surf/Contour Plot

What is a MATLAB surf/contour plot?

A MATLAB surf/contour plot is a type of 2D or 3D graph that displays the relationship between two independent variables and a dependent variable using contour lines or a surface plot.

How do I find the volume under a surf/contour plot in MATLAB?

To find the volume under a surf/contour plot in MATLAB, you can use the "trapz" function to numerically integrate the data points on the plot. First, you will need to convert the contour lines or surface plot into a matrix of data points. Then, you can use the "trapz" function to integrate the data points and calculate the volume.

Can I find the volume under a surf/contour plot for any type of data?

Yes, you can find the volume under a surf/contour plot for any type of data as long as it can be represented as a 2D or 3D plot in MATLAB. This includes data from experiments, simulations, or mathematical functions.

What are some potential applications for finding the volume under a surf/contour plot?

Finding the volume under a surf/contour plot can be useful in many fields, such as engineering, physics, and biology. It can be used to calculate the volume of an object or substance, determine the area under a curve, or analyze data from experiments or simulations.

Are there any other methods besides "trapz" for finding the volume under a surf/contour plot in MATLAB?

Yes, there are other methods for finding the volume under a surf/contour plot in MATLAB, such as the "quad" function and the "integral2" function. These methods may be more suitable for certain types of data or provide more accurate results in certain situations.

Back
Top