Solving for area under graph in matlab

  • MATLAB
  • Thread starter kthejohnster
  • Start date
  • #1

Main Question or Discussion Point

how could i use matlab to find area under graph using numerical methods that the integral of flow vs time graph is 1/T*sum(Qti)dt or at least i think thats what the formula is, if not please help
 

Answers and Replies

  • #2
chiro
Science Advisor
4,790
132
how could i use matlab to find area under graph using numerical methods that the integral of flow vs time graph is 1/T*sum(Qti)dt or at least i think thats what the formula is, if not please help
Hey kthejohnster and welcome to the forums.

For this problem (even in MATLAB) you just a standard numerical integration routine if you have an array of values (in any dimension).

Are you familiar with numerical integration schemes? Here is something to get you started:

http://en.wikipedia.org/wiki/Numerical_integration
 
  • #3
Hey kthejohnster and welcome to the forums.

For this problem (even in MATLAB) you just a standard numerical integration routine if you have an array of values (in any dimension).

Are you familiar with numerical integration schemes? Here is something to get you started:

http://en.wikipedia.org/wiki/Numerical_integration
Thanks, I know that the integral is equal to the sum of value * dt for the time but dont know how to write it in matlab. I have my plot x_plot and its a periodic function with period T how would I calculate the area under 1 period?
 
  • #4
chiro
Science Advisor
4,790
132
Thanks, I know that the integral is equal to the sum of value * dt for the time but dont know how to write it in matlab. I have my plot x_plot and its a periodic function with period T how would I calculate the area under 1 period?
Well the idea is that if you have the values for a function at regular intervals you use a numerical technique to get an approximation of the area under the curve of the function (which is just the integral using the right limits).

The easiest way to get an approximation is to use the midpoint method which goes something like this:

Lets say you have two function values f(a) and f(a+h), then the approximated area for f(a) to f(a+h) is h x [f(a+h)+f(a)]/2. Using this formula you apply it to all your data points and you get an approximation for the integral.

This is not the best method to use, but its a good way to demonstrate what I am referring to in terms of numerical integration.

If you want some kind of numeric answer I strongly suggest you look at the wikipedia page and then look at the various schemes that are available.
 
  • #5
jhae2.718
Gold Member
1,161
20
Can you use MATLAB built-ins like trapz or quad?
 

Related Threads on Solving for area under graph in matlab

Replies
5
Views
12K
Replies
5
Views
844
Replies
4
Views
29K
Replies
4
Views
10K
  • Last Post
Replies
2
Views
1K
Replies
2
Views
2K
Replies
6
Views
3K
Replies
0
Views
4K
Top