The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
calculate average cdfd123 High Level Programming 3 11-13-2008 12:23 PM
calculate average of multiple line data smacherla HP-UX 4 05-23-2008 05:39 PM
Average Time sambond UNIX for Dummies Questions & Answers 1 01-16-2008 10:57 AM
Use awk to calculate average of column 3 grossgermany UNIX for Dummies Questions & Answers 6 07-27-2007 02:29 PM
calculate average of column 2 onthetopo UNIX for Dummies Questions & Answers 0 07-06-2007 09:16 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-23-2008
nica nica is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 23
calculate the average of time series data using AWK

Hi,

I have two time series data (below) merged into a file.
t1 and t2 are in unit of second

I want to calculate the average of V1 every second and count how many times "1" in V2 is occur within a second


Input File:

t1 V1 t2 V2
10.000000 4.387413 10.139355302 1
10.100000 4.397372 10.252770182 1
10.200000 4.406951 10.398060182 1
10.300000 3.940732 10.515105302 1
10.400000 4.044359 10.645365302 1
10.500000 4.139778 10.768800182 1
10.600000 4.222087 10.929725222 1
10.700000 4.299174 11.106285302 1
10.800000 2.941378 11.216505302 1
10.900000 3.081282 11.324910182 1
11.000000 3.219284 11.626115222 1
11.100000 3.354575 11.822715302 1
11.200000 3.486347 11.968005302 1
11.300000 3.613792 12.107075222 1
11.400000 3.730119 12.233535302 1
11.500000 3.846800 12.377615222 1
11.600000 3.956768 12.494055302 1
11.700000 4.059215 12.642540182 1
11.800000 4.153333 12.742740182 1
11.900000 4.234293 12.853565222 1
12.000000 4.309844 13.093440182 1
12.100000 2.107283 13.209275222 1
12.200000 2.234828 13.343940182 1
12.300000 2.371988 13.471005302 1
12.400000 2.511328 13.635125222 1
12.500000 2.652041 13.824900182 1
12.600000 2.793317 13.955160182 1
12.700000 2.934348 14.082225302 1
12.800000 3.067364 14.185620182 1
12.900000 3.205592 14.302665302 1
13.000000 4.130738 14.421090182 1
13.100000 3.929949 14.707265222 1
13.200000 2.160613 14.828715302 1
13.300000 2.296229 14.938935302 1
13.400000 2.434470 15.114285302 1
13.500000 2.574528 15.242730182 1
13.600000 3.865811 15.485025302 1
13.700000 4.273357 15.660375302 1
13.800000 4.357861 15.895845302 1
13.900000 4.371735 16.034310182 1
14.000000 4.377158 16.150145222 1
..............
..............



Desired Output:

t1 V1 V2
10.000000 3.986053 7
11.000000 3.765453 6
12.000000 2.818793 7
13.000000 3.439529 7
...............
...............


Please, can anyone tell me AWK code for calculating this..??

Thanks
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0