Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Apr 13, 2008 #1
    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.

    Can someone please help?

    Thanks and cheers
    vivek
     
    Last edited by a moderator: Apr 23, 2017
  2. jcsd
  3. Apr 13, 2008 #2
    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))
     
  4. Apr 13, 2008 #3
    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...
     
  5. Apr 14, 2008 #4
    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.
     
  6. Apr 20, 2008 #5
    Thanks
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook




Loading...
Similar Threads for MATLAB help determining Date
MATLAB MATLab: Not enough inputs for nlinfit Nov 16, 2017
MATLAB Help needed to fix a matlab code Nov 8, 2017
New to Matlab, help with vectors Feb 20, 2016
Need help with integral Dec 23, 2015
MATLAB 2D diffusion equation, need help for matlab code. Nov 7, 2015