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
 How to select the maximum values

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
rainbowkoala Posted - 10/31/2013 : 04:50:10 AM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8.5.0 SR1
Operating System: win7
Step 1 find the maximum value in column Y5 of Worksheet 0
Step 2 put the maximum value in column Y5 and the corresponding value in column X5 into Worksheet Tg.
Step 3 repeat step 1 and 2 to put the maximum values in column Y4/Y3/Y2/Y1 and the corresponding values in column X4/X3/X2/X1 of Worksheet 0 into Worksheet Tg.
Step 4 repeat step 1-3 to put the maximum values in column Y5/Y4/Y3/Y2/Y1 and the corresponding values in column X5/X4/X3/X2/X1 in Worksheet 4/8/20/40/60/80 into Worksheet Tg.

Please find more details in the insert images.
The original data is in the attachment.
Thanks for your help.




http://www.originlab.com/ftp/forum_and_kbase/Images/maximum.ogw
6   L A T E S T    R E P L I E S    (Newest First)
lkb0221 Posted - 11/04/2013 : 12:25:58 PM
Hi,

Sorry the "range -v" is a new feature in Origin9.1
I modified the script and tested in a 85 machine by your Maximum2.opj.
Hope this time it will help.

int bt = page.nlayers;
int st1, tti;
range rr1 = $(bt)!;
for (nn=1;nn<bt;nn++)
{
range rr2 = $(nn)!;
st1 = rr2.ncols;
for (kk=st1;kk>0;kk-2)
{
range rr3 = $(nn)!col($(kk));
limit rr3;
tti = limit.imax;
range rr4 = $(nn)!col($(kk-1))[$(tti)];
range rr5 = $(bt)!col($(nn*2))[$(st1/2-kk/2+1)];
rr5 = rr4;
range rr4 = $(nn)!col($(kk))[$(tti)];
range rr5 = $(bt)!col($(nn*2+1))[$(st1/2-kk/2+1)];
rr5 = rr4;
tti=0;
}
}

Thanks,
Zheng
rainbowkoala Posted - 11/01/2013 : 12:04:36 AM
Hi, Zheng
Thank you so much.
I am sorry, but I am still having problem with the script.
I am a beginner in using script. I selected Window:Script Window and pasted in the script you gave,and hit the Enter key, however, it did not work.

Please use the link below to download the original data.
https://skydrive.live.com/redir?resid=C3B36982D2C703C7!113&authkey=!ACSagrFnSN-vh6s






quote:
Originally posted by lkb0221

Hi,

You can try the following script. I assume your sheets 0/4/8/.../80 all have XYXY structure.
The script does not set the the first column in the last worksheet(Tg) because I'm not sure whether all the former sheets has the same column short names.
Hope this will help you.

int bt = page.nlayers;
int st1, tti;
range rr1 = sheet$(bt)!;
for (nn=1;nn<bt;nn++)
{
range rr2 = sheet$(nn)!;
st1 = rr2.ncols;
for (kk=st1;kk>0;kk-2)
{
range rr3 = sheet$(nn)!col($(kk));
limit rr3;
tti = limit.imax;
range -v rr4 = sheet$(nn)!col($(kk-1))[$(tti)]:col($(kk))[$(tti)];
range -v rr5 = sheet$(bt)!col($(nn*2))[$(kk/2)]:col($(nn*3))[$(kk/2)];
rr5 = rr4;
}
}

Zheng
rainbowkoala Posted - 10/31/2013 : 11:18:57 PM
Hello, Snow
Thank you so much.
Please use the link below to download the original data.
https://skydrive.live.com/redir?resid=C3B36982D2C703C7!109&authkey=!AGifeFNH8Bw1Elc

And I followed your advice, however, when I set condition to be mod(i,2)==1 and choosed to output it to New worksheet, it did not copy all X values to a new sheet, as you can see in the pic I added (eg. Worksheet 0). The data were extracted from Sheet1. Why does it not work?








quote:
Originally posted by snowli

Hello,

I couldn't download your data.

Origin supports statistics on columns. So you can first calculate the maximum value of all columns you want. Then do the copy and paste.

Here is how to do statistics on multiple columns in all worksheets of a workbook.

1, With the worksheet 0 active, you can choose Statistics: Descriptive Statistics: Statistics on Columns... menu.
2. In the dialog that opens, click the > button next to Range 1: Data Range box and choose Select Columns... context menu.
3. In the Column Browser, choose
List Columns in Current workbook.
--> It will list all columns in all worksheets (0, 4, 8, etc.)
U can select all columns you want to get maximum value on and click Add to add them into the bottom panel.
Then click OK to go back to Statistics on Columns dialog.
4. Under Quantities to computer. Uncheck all moments. Under Quantiles node, only keep Maximum checked.
5. Click OK.
--> U will get a result sheet with all maximum values calculated for all the columns you selected in Descriptive Statistics table.
6. Right click the Descriptive Statistics table and choose Create Copy as New Sheet.
7. A new sheet will be created.
8. U can reorganize the data so they are easier to be paste to the destination.


The following is a way to reorganize data better to do your copy and paste.
With the new sheet created, choose Worksheet: Worksheet Query...
Only Check Maximum column since that's the column you want to extract.
set condition to be mod(i,2)==1
Choose to output it to New worksheet.
It will copy all X values to a new sheet.
Then go back to the new sheet, and choose Worksheet: Worksheet Query... again.
Only Check Maximum column since that's the column you want to extract.
This time set condition to be mod(i,2)==0
Choose to output it to Specified worksheet. And use the > button to select the previous extracted sheet name.
Click OK
==> It will be easier to copy and paste maximum XY values now.

Hope it helps,
Thanks, Snow
lkb0221 Posted - 10/31/2013 : 3:19:24 PM
Hi,

You can try the following script. I assume your sheets 0/4/8/.../80 all have XYXY structure.
The script does not set the the first column in the last worksheet(Tg) because I'm not sure whether all the former sheets has the same column short names.
Hope this will help you.

int bt = page.nlayers;
int st1, tti;
range rr1 = sheet$(bt)!;
for (nn=1;nn<bt;nn++)
{
range rr2 = sheet$(nn)!;
st1 = rr2.ncols;
for (kk=st1;kk>0;kk-2)
{
range rr3 = sheet$(nn)!col($(kk));
limit rr3;
tti = limit.imax;
range -v rr4 = sheet$(nn)!col($(kk-1))[$(tti)]:col($(kk))[$(tti)];
range -v rr5 = sheet$(bt)!col($(nn*2))[$(kk/2)]:col($(nn*3))[$(kk/2)];
rr5 = rr4;
}
}

Zheng
snowli Posted - 10/31/2013 : 1:25:26 PM
Hello,

I couldn't download your data.

Origin supports statistics on columns. So you can first calculate the maximum value of all columns you want. Then do the copy and paste.

Here is how to do statistics on multiple columns in all worksheets of a workbook.

1, With the worksheet 0 active, you can choose Statistics: Descriptive Statistics: Statistics on Columns... menu.
2. In the dialog that opens, click the > button next to Range 1: Data Range box and choose Select Columns... context menu.
3. In the Column Browser, choose
List Columns in Current workbook.
--> It will list all columns in all worksheets (0, 4, 8, etc.)
U can select all columns you want to get maximum value on and click Add to add them into the bottom panel.
Then click OK to go back to Statistics on Columns dialog.
4. Under Quantities to computer. Uncheck all moments. Under Quantiles node, only keep Maximum checked.
5. Click OK.
--> U will get a result sheet with all maximum values calculated for all the columns you selected in Descriptive Statistics table.
6. Right click the Descriptive Statistics table and choose Create Copy as New Sheet.
7. A new sheet will be created.
8. U can reorganize the data so they are easier to be paste to the destination.


The following is a way to reorganize data better to do your copy and paste.
With the new sheet created, choose Worksheet: Worksheet Query...
Only Check Maximum column since that's the column you want to extract.
set condition to be mod(i,2)==1
Choose to output it to New worksheet.
It will copy all X values to a new sheet.
Then go back to the new sheet, and choose Worksheet: Worksheet Query... again.
Only Check Maximum column since that's the column you want to extract.
This time set condition to be mod(i,2)==0
Choose to output it to Specified worksheet. And use the > button to select the previous extracted sheet name.
Click OK
==> It will be easier to copy and paste maximum XY values now.

Hope it helps,
Thanks, Snow

rainbowkoala Posted - 10/31/2013 : 04:52:53 AM
I just want to ask if there is a simple way to do the steps.

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