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
 Variables inside loops

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
HaroldPit2 Posted - 12/14/2011 : 4:34:28 PM
Origin Ver. and Service Release: Origin Pro 8.5.0G SR1
Operating System: WinXP

I want to average(arithmetic mean) over several columns. I want this to be done using a user input, that specifies over how many columns the averaging has to be done and with which column to start. I tried various things and I have a rough idea what I want:

loop (i,$(firstaveragingcolumn), $(firstaveragingcolumn) + $(numberofcolumns))
{
	%M=$(i);
	%N=Col;
	%O=%M%N;
	range %O=wcol(i+1);
}
range colmed = Averages!col(2);
colmed = (col1+col2+....)/$(reps);


I essentially need a loop that spits out all the columns defined per the variables for further processing. I noticed that the ranges are only existent inside the loop, so I'm at a loss what to do here.

In case I didn't get my point across please ask for clarification.
2   L A T E S T    R E P L I E S    (Newest First)
couturier Posted - 12/16/2011 : 04:46:21 AM
You can use the following script:

int colbegin=2, colend=6; // define here begin and end column
range activesheet=!, result=Averages!2; // define active sheet for performing average, and where to put result
sum(%(activesheet),colbegin,colend); // compute stats from begin to end cols
result=_mean;
del _mean; // the sum function will compute various stat parameters
del _sd; // that are stored in those hidden datasets
del _max; // I delete them after to clear up memory
del _min; // Before deleting, you can also use any of them
del _range;
del _npts;

This method is the fastest as far as I know
LabTalk user Posted - 12/15/2011 : 11:40:09 AM
Hi,

You can try forcing global scope on the variables.
@global = 1; //This forces all following variables to global scope
@global = 0; //Sets all following variables to standard scope
For more on scope see: http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Data_Types_and_Variables

If that doesn't work, try using non-string register variable names. I've noticed weird things happen when I use string registers too much.
See: http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:String_registers

Hope this helps!

-P

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