Solving for area under graph in matlab

  • Context: MATLAB 
  • Thread starter Thread starter kthejohnster
  • Start date Start date
  • Tags Tags
    Area Graph Matlab
Click For Summary

Discussion Overview

The discussion revolves around using MATLAB to calculate the area under a flow versus time graph through numerical integration methods. Participants explore various techniques and seek clarification on implementing these methods in MATLAB, particularly for periodic functions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant inquires about using MATLAB for numerical integration to find the area under a flow versus time graph, suggesting a formula involving the integral and summation.
  • Another participant suggests using standard numerical integration routines available in MATLAB for approximating the area under the curve if an array of values is provided.
  • A participant mentions the integral as the sum of value multiplied by dt and seeks guidance on how to implement this in MATLAB for a periodic function.
  • There is a discussion about using the midpoint method for numerical integration, where an approximation of the area is derived from function values at regular intervals.
  • A question is raised about the possibility of using MATLAB built-in functions like trapz or quad for the integration process.

Areas of Agreement / Disagreement

Participants express varying levels of familiarity with numerical integration methods, and while some suggest specific techniques, there is no consensus on the best approach or method to use in MATLAB.

Contextual Notes

Participants reference various numerical integration methods and their applicability, but there is uncertainty regarding the most effective method for the specific problem of integrating a periodic function in MATLAB.

kthejohnster
Messages
23
Reaction score
0
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 that's what the formula is, if not please help
 
Physics news on Phys.org
kthejohnster said:
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 that's 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
 
chiro said:
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 don't 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?
 
kthejohnster said:
Thanks, I know that the integral is equal to the sum of value * dt for the time but don't 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.
 
Can you use MATLAB built-ins like trapz or quad?
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K