mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			10 lines
		
	
	
		
			292 B
		
	
	
	
		
			Matlab
		
	
	
	
	
	
			
		
		
	
	
			10 lines
		
	
	
		
			292 B
		
	
	
	
		
			Matlab
		
	
	
	
	
	
| function y = average(x)
 | |
| % AVERAGE Mean of vector elements.
 | |
| % AVERAGE(X), where X is a vector, is the mean of vector
 | |
| % elements. Nonvector input results in an error.
 | |
| [m,n] = size(x);
 | |
| if (~((m == 1) | (n == 1)) | (m == 1 & n == 1))
 | |
|     error('Input must be a vector')
 | |
| end
 | |
| y = sum(x)/length(x);
 |