sortx.m

来自「approximate reinforcement learning」· M 代码 · 共 28 行

M
28
字号
function a = sortx(a, th, lb, ub)% Extended sort%   A = SORTX(A, TH, LB, UB)% Sort a vector removing (fuzzy) duplicates and bounding elements%% Parameters:%   A       - the array to sort%   TH      - (optional) threshold for different elements. If the distance between two consecutive%           elements is at most TH, only the smaller one will be kept. Default 0.%   LB      - (optional) the lower bound for the elements%   UB      - (optional) the upper bound for the elements% Returns:%   A   - the sorted array, with duplicates removed, and optionally %       bounded elementsif nargin < 2,     th = 0;end;if nargin < 3,    lb = -Inf;    ub = Inf;end;a(a < lb) = lb; a(a > ub) = ub;   % bounda = sort(a); a = [a(diff(a) > th) a(end)];     % remove (fuzzy) duplicates

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?