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 help needed

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
ringman7677 Posted - 04/16/2001 : 10:55:43 AM
I have bee pounding my head long enough on this scripting and could use a solution if it is possible.

After importing a ascii data file, with an unknown number of rows and columns, I would like to find the average of the first 10 values in a column and subtract that average from every value in the same column overwriting the original value. This would be applied to every column except the first (which contains a time stamp). I think this is similar, without the averaging, to the vertical translate command in the plot analysis drop down menu.

Thanks
1   L A T E S T    R E P L I E S    (Newest First)
rtoomey Posted - 04/16/2001 : 5:11:23 PM

Below is an example script which performs the necessary calculations on the active dataset (column). To activate a dataset, select the corresponding column in your worksheet. Alternatively, activate it in a graph window by selecting the dataset from the list at the bottom of the Data menu. Once activated, highlight the script (after pasting it in the Script window) and press the ENTER key on your keyboard.



total=0;
loop (ii,1,10) {total=total+%C[ii];}; // sum up first ten cells
total=total/10; // average them
(%C)=(%C)-total; // subtract total from active dataset


Note: %C is enclosed in ( ) to force the string inside %C to be expressed before assignment (before the vector calculation ensues). This is required.

To apply this script to every column (except the first), place the calculations above in another loop which goes from 2 to wks.ncols. Use the worksheet -s command option to activate each successive column in the loop. Be sure to use a different index variable (i.e. jj instead of ii) for the second loop.



Good Luck!
Ryan




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