selectd.m

来自「GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角」· M 代码 · 共 30 行

M
30
字号
%                             selectd.m
%  Scope:   This MATLAB macro selects only the different elements from a
%           specified array.
%  Usage:   [xsel,nsel] = selectd(x)
%  Description of parameters:
%           x     -  input, columnwise array containing elements to be 
%                    selected
%           xsel  -  output, array containing selected elements, vector with
%                    nsel  elements
%           nsel  -  output, number of elements in the array xsel
%  Last update:  04/23/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function [xsel,nsel] = selectd(x)

[nrow,ncol] = size(x);
if (nrow == 1) | (ncol ~= 1)
   error('Error in SELECTD.M; check the dimension of the input array');
end

y = sort(x);
nsel = 1;
xsel(1) = y(1);

for k = 2:nrow
   if y(k) ~= y(k-1)
      nsel = nsel + 1;
      xsel(nsel) = y(k);
   end
end

⌨️ 快捷键说明

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