The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Average of 5 last datapoints

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
KristianWW Posted - 03/08/2017 : 06:09:13 AM
Hi

I am struggeling finding a code that can take the average of the 5 last "high value" datapoints of a series with several datapoints.
My datapoints looks like this:




The length of the low values varies a bit as well as the length of the high values. The picture is just a snapshot, as the datasheet have several thousand datapoints.
3   L A T E S T    R E P L I E S    (Newest First)
arstern Posted - 03/13/2017 : 3:17:18 PM
Hi,

You can add a filter to find the top 5 values.
http://www.originlab.com/doc/Origin-Help/Wks-DataFilter

With the column filter added, click the filter icon that will be located in the column. Select top 10. Collection should read 'Top' and input 5 for number. This will filter the top 5 values without sorting. Then you can take the average.


You can either take the average by creating a new column. In the F(X) input mean(Col(A)). Assuming column A is the column filled data.

If you don't want to create a new column. You can also calculate the average from the filtered column by using the command line or script window.

i.e. Below is what you can type in the command/script window
average = mean(col(A));
average=;

Hope this helps.

--OriginLab
Aviel Stern
KristianWW Posted - 03/13/2017 : 09:26:02 AM
Hi

the only problem is that the datapoints are fixed in time and cannot be sorted with respect to their values. The values are readings in an experiment and to visualize the data in the best way is to take the average of the five last values before the value switches to be close to zero shown in the picture above.

The probalble solution I think of is to have a for loop that saves the values between the zeroes and then take the average of the last five saved values, before going to the next collection of values above zero.
arstern Posted - 03/08/2017 : 10:45:29 AM
Hi Kristian,

There are multiple ways to go about finding the average for the last maximum values. One method is to first sort your column in descending order. Right click on the column and select sort column --> descending. Next insert a new column where the average will be calculated. In the New column, open the dialog box for F(x). In the blank box, type ave(col(a),5). This takes the average for every 5 rows. To specify you only want the first five rows. In Row(i) input From 1 to 1.

You could also write a simple command in the script window to do all these steps. Refer to the LabTalk programming tutorial.




--Aviel Stern
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000