-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function y = range(x,dim) | ||
%RANGE Sample range. | ||
% Y = RANGE(X) returns the range of the values in X. For a vector input, | ||
% Y is the difference between the maximum and minimum values. For a | ||
% matrix input, Y is a vector containing the range for each column. For | ||
% N-D arrays, RANGE operates along the first non-singleton dimension. | ||
% | ||
% RANGE treats NaNs as missing values, and ignores them. | ||
% | ||
% Y = RANGE(X,DIM) operates along the dimension DIM. | ||
% | ||
% See also BOUNDS, MIN, MAX, IQR, MAD, STD. | ||
|
||
% Copyright 1993-2016 The MathWorks, Inc. | ||
|
||
|
||
if nargin < 2 | ||
y = max(x) - min(x); | ||
else | ||
y = max(x,[],dim) - min(x,[],dim); | ||
end |