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 for Programming
 LabTalk Forum
 Grouping data in intervals2
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Force

Denmark
9 Posts

Posted - 09/10/2014 :  05:19:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):9.1 pro
Operating System: win7

Hi,
This is an urgent question/problem that I hope someone can help me with. Some time ago I was advice by Greg to use the following scrip to reduce my data by grouping and calculate the sum in each interval. I worked fine on a test file however when I use real data it does not work. As far as I can see it is related to missing data points in col 7. When I sort col 7 the first number of rows does not include data. Do I need to redefine the row start or remove rows in col7 after sorting? I really appreciate if someone could help me with the missing code in the script.



wsort bycol:=7 c1:=7 c2:=9;

range ra1 = 7, ra2 = 8, ra3 = 9; // your X,Y columns
wks.addcol(10); // To receive groupX;
range ra4 = $(wks.ncols);
wks.addcol(11); // To receive groupY
range ra5 = $(wks.ncols);
wks.addcol(12); // To receive groupY
range ra6 = $(wks.ncols);
// Initialize
xincr = 10;
xstart = ra1[1];
rowstart = 1;
row = 1;

loop(ii,2,ra1.GetSize())
{
xval = ra1[ii];
if(xval>= xstart + xincr)
{
// Summarize
ra4[row] = xstart + xincr;
stats ra2[rowstart:ii-1];
ra5[row] = stats.sum;
stats ra3[rowstart:ii-1];
ra6[row] = stats.sum;
row++;
xstart = xstart + xincr;
rowstart = ii;
}
}
// Final group
ra4[row] = ra1[ii-1];
stats ra2[rowstart:ii-1];
ra5[row] = stats.sum;
stats ra3[rowstart:ii-1];
ra6[row] = stats.sum;

greg

USA
1378 Posts

Posted - 09/10/2014 :  09:51:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Change this line:

wsort bycol:=7 c1:=7 c2:=9;

to this:

wsort bycol:=7 c1:=7 c2:=9 missing:=1;

That will put all the missing values at the end.
Go to Top of Page

Force

Denmark
9 Posts

Posted - 09/11/2014 :  08:12:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Such a small change - but what a huge effect for my calculations - amazing. Thanks Greg.

One more thing though. I have merged two graphs with two left and right y-axis (y1 and y2). However, I can't find out how to show the y2 axis label (and specify the name). Could you show me how or guide me to where on the homepage it is shown? With many graphs one get tired of placing them manually after running the script.


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