Solved

# Integration of time series data

Posted on 2009-07-16
1,412 Views
Helo- I have columns of time history data as shown below. How do I do integration of these data and write in a separate column, i. e., in"Integrated values" column? Do I have to use trapizoidal rule, or simpson rule? Any example of MATLAB command or code will help. Thanks.

time Value   Integrated values
0        0.1
0.1     2
0.2     3
0.4     1
0
Question by:okd
• 2

LVL 15

Expert Comment

What method to use for integration is up to you. Trapezoidal integration is build into Matlab. If you imported time as x and Value as y, you can do integration as z=trapz(x,y);
If you also need help to import/output data, please tell more details on your original data format and what you want as output. How large is the dataset? You can also attach an example here.
0

Author Comment

Thank you. Could you also send me how to import and output data in MATLAB. The database is like I have sent you, but it has 500 rows. I want to plot the time vs. z=trapz(x,y) values. Matlab commands for plotting and import/output data will help the most. Thanks again, - okd
0

LVL 15

Accepted Solution

yuk99 earned 125 total points
Here is the code. It read the data from tab-delimited file tsdata.txt and returns 2-column matrix data. To make it clear I put time into time vector and value into value vector (rows 2 and 3). TRAPZ function will return only one value - the total area under the curve for the whole vector. To get integrated value for every time point you can use CUMTRAPZ.
``````% data import

% let's split variables for clarity

time=data(:,1);

value=data(:,2);

% calculating integrated values

intvalue=cumtrapz(time,value);

% plotting

plot(time,intvalue)
``````
0

## Featured Post

### Suggested Solutions

Help with my python script 6 143
centeredAverage challenge 8 119
tenRun challenge 28 81
mapAB Challlenge 35 83
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.