Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Integration of time series data

Posted on 2009-07-16
3
1,543 Views
Last Modified: 2016-02-10
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
Comment
Question by:okd
  • 2
3 Comments
 
LVL 15

Expert Comment

by:yuk99
ID: 24873434
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

by:okd
ID: 24896016
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

by:
yuk99 earned 125 total points
ID: 24897374
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
data=dlmread('tsdata.txt','\t',1,0);
% let's split variables for clarity
time=data(:,1);
value=data(:,2);
% calculating integrated values
intvalue=cumtrapz(time,value);
% plotting
plot(time,intvalue)

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
map interface methods 3 72
copyEndy  challenge 15 97
Change to event 1 117
groovy example issue 10 103
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.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question