# MATLAB help: determining the area under a plot (not a curve whose form is known)

## Main Question or Discussion Point

Hi

For a project (described https://www.physicsforums.com/showthread.php?t=227684"), I have to do the following for N images:

1. plot the histogram of each image, using

imhist(x)

2. plot a curvilinear approximation to the histogram, using

plot(imhist(x))

3. determine the area under the plot generated in step 2

4. Plot a curve of area value versus image number (index) and determine the image number for which the area value is a minimum.

I am not sure how to do step 3 and also whether steps 1 and 2 are correct.

Thanks and cheers
vivek

Last edited by a moderator:

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
If step 2 is continuous then try the MATLAB command 'trapz'.
Go:
help trapz
in the MATLAB command window. Hopefully you can do:
trapz(imhist(x))

Should I do

trapz(imhist(x))

or

trapz(plot(imhist(x))

?

plot(imhist(x)) plots the histogram with the peaks joined by a not-so-smooth curve...

You should do:
trapz(imhist(x))

Now you say that plot(imhist(x)) plots a histogram with peaks joined by a curve? I assume you want the area under that curve? If thats the case I don't think trapz will help - you need to JUST plot the peaks and trapz will give the area under that curve.

Thanks