- #1
kthejohnster
- 23
- 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
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
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
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?
To calculate the area under a graph in Matlab, you can use the trapz function, which calculates the approximate area under a curve using the trapezoidal rule. This function takes in two arguments: the vector containing the x values and the vector containing the y values. It then returns the approximate area under the curve.
Yes, you can calculate the area under multiple curves in Matlab by using the trapz function for each curve separately and then summing up the results. You can also use the integral function to calculate the exact area under a curve, which allows for multiple curves to be inputted at once.
Yes, the trapz function in Matlab takes into account both positive and negative values when calculating the area under a curve. As long as the x and y vectors are correctly inputted, the area under the entire curve will be calculated accurately, regardless of the presence of negative values.
Yes, you can plot the area under a graph in Matlab by using the fill function. This function takes in the x and y vectors and fills in the area between the curve and the x-axis. You can also use the area function, which plots the area and adds it to the existing plot.
Yes, you can calculate the area under a graph for a specific section or interval by specifying the indices of the x and y vectors that correspond to that section. You can then use the trapz function on these selected indices to calculate the area under the curve for that specific interval.