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
 Script to extrapolate y values from many columns

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
surjpanj Posted - 06/02/2021 : 09:11:33 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2018
Operating System: Win 10

Hi,

I need a script that would extrapolate y values from a specified set of x values (i.e., function Extrapolate Y from X in the Analysis/Mathematics menu), run through specified columns (e.g. Col(C), Col(E), Col(G),...) and write the extrapolated values in a new sheet. The extrapolated values should be written only in one column (i.e., Col(C) followed by Col(E) values, Col(G) values, etc). I would also need that extrapolated values are rounded to only one decimal place and if the value is negative, it should be set to zero. The script should run through all workbooks in the project.

A lot to ask I know but I appreciate the help.

Thanks,
Matt
5   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 06/04/2021 : 4:41:18 PM
For further help, please contact us using the ticket system below and provide your serial number in the message. Thank you.
https://www.originlab.com/restricted/support/index.aspx?c=3

James
surjpanj Posted - 06/04/2021 : 09:51:48 AM
Thanks James! Please help me solve several more issues.

1. If I use script: for (j = 4; j <=wks.nCols; j = j + 2) {interp1 ix:=Col(1) iy:=wCol(j) ox:= [book2]Sheet2!<new>}; then the script runs only on the first column. I need to manually create book2 for script to run over all columns. What command can I use to create a new woorkbook and then rename it the same as the original woorkbook with an extension "_b"?

2. wstackcol -r 2; this command only works if I manually highlight all the columns. The results are given in two columns where the first column contains useless information. I only need data on the second column.

3. The data in the long column should be rounded only to one decimal place and if the value is negative, it should be set to zero.

As I mentioned, I literally have more than 100 workbooks where I need to do such processing therefore the script should automate all of the above steps.

I appreciate your help.
Matt
YimingChen Posted - 06/03/2021 : 11:51:59 AM
1. you may first prepare a workbook to save the result to columns. e.g.
interp1 ix:=Col(1) iy:=wCol(j) ox:=[book2]Sheet2!<new>;


2. Then you may want to stack all cols into one long column.
wstackcol -r 2;


3. To export worksheet, use
expASC path:="C:\test.dat"


Please also check the details of the X-function that is used.

James
surjpanj Posted - 06/03/2021 : 07:49:09 AM
Hi James,

thanks for pointing me to the references. So far I managed to write a script, which applies the extrapolate function on the selected columns of the worksheet (see script below). However, the extrapolated values should be written in a new sheet (possibly renamed as "original sheet name"_a). Then, the new columns should be arranged one after another as a one long column (maybe in another sheet with name "original sheet name"_b). Can you please help me solve this?

I have hundred worksheets where I need to do such processing. Finally, I will need to export the long columns into individual txt files (named as e.g. "original sheet name"_b.txt ).

Thanks,
Matt

doc -e W {
for (j = 4; j <=wks.nCols; j = j + 2)
{interp1 ix:=Col(1) iy:=wCol(j)}
}
YimingChen Posted - 06/02/2021 : 12:14:06 PM
Please refer to this X-function page on interpolation.
https://www.originlab.com/doc/X-Function/ref/interp1

To loop through all workbooks, please use
doc -e W {}

Please refer to https://www.originlab.com/doc/labtalk/ref/document-cmd#-e_object_.7Bscript.7D.3B_Execute_the_given_script_for_all_objects

For further help, please contact us use the ticket system.
https://www.originlab.com/restricted/support/index.aspx?c=3

James

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