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
 script help needed
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ringman7677

USA
16 Posts

Posted - 04/16/2001 :  10:55:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

rtoomey

USA
184 Posts

Posted - 04/16/2001 :  5:11:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

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



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