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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Average of 5 last datapoints
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

KristianWW

Norway
2 Posts

Posted - 03/08/2017 :  06:09:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

arstern

USA
237 Posts

Posted - 03/08/2017 :  10:45:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - arstern on 03/08/2017 10:52:59 AM
Go to Top of Page

KristianWW

Norway
2 Posts

Posted - 03/13/2017 :  09:26:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.

Edited by - KristianWW on 03/13/2017 09:28:38 AM
Go to Top of Page

arstern

USA
237 Posts

Posted - 03/13/2017 :  3:17:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000