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
 Problem using mean function

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
jones.4264 Posted - 08/16/2013 : 2:10:15 PM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: 7

My program is supposed to take subsets of columns x and y and find the mean of these values. Currently the value it is outputting is much higher than the actual mean. Any help would be appreciated.
type "program started";
	double maximum, frames;
		

	maximum = max(col(2));
	frames = 695;
	for(i=1; i<=maximum+1; i++) {
		double start, end, meanx, meany, maxx, minx, maxy, miny;
		//type" in the sum x";
		start = 1+frames*(i-1);
		end = (frames + frames*(i-1));
		type "start = $(start) end = $(end)";
		range r1 = Col(X)[start:end];
		meanx=mean(r1);
		maxx=max(r1);
		minx=min(r1);
		//type "through sum x";
		//meanx= (sum.mean);
		col(13)[i] = meanx;
		type "mean = $(meanx)";
		
		
		//type "in sum y";
		range r2 = Col(Y)[start:end];
		meany= mean(r2);
		maxy= max(r2);
		miny= min(r2);
		//type "through sum y";
		col(14)[i] = meany;
		col(16)[i] = (maxx - minx)/2;
		col(17)[i] = (maxy - miny)/2;
		//type "meany done";
		list a;
	}
	
	for (i=1; i<=maximum+1; i++){
		mx = col(13)[i];
		my = col(14)[i];
		mr = sqrt(mx^2 + my^2);
		col(15)[i] = mr;
	}
	
	
		
	
	
	type "program ended";
1   L A T E S T    R E P L I E S    (Newest First)
Shirley_GZ Posted - 08/19/2013 : 06:28:26 AM
Hi Jones,

Please change the range defination lines as below:

......
range r1 = Col(X)[$(start):$(end)];
......
range r2 = Col(Y)[$(start):$(end)];
......



Originlab Technical Service Team

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