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 for Programming
 LabTalk Forum
 Grouping data in intervals2

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
Force Posted - 09/10/2014 : 05:19:00 AM
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;
2   L A T E S T    R E P L I E S    (Newest First)
Force Posted - 09/11/2014 : 08:12:22 AM
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.


greg Posted - 09/10/2014 : 09:51:27 AM
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.

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