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
 Problem using mean function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jones.4264

USA
1 Posts

Posted - 08/16/2013 :  2:10:15 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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";

Shirley_GZ

China
Posts

Posted - 08/19/2013 :  06:28:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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