nonduplicate

バージョン 2.0.0.0 (1.84 KB) 作成者: Nathan Tomlin
Makes all values of input array distinct - used to get interp1 to work when x data has duplicates.
ダウンロード: 1K
更新 2019/3/21

ライセンスの表示

% function xout = nonduplicate(xin)
%
% written so that interp1 doesn't return error:
% 'The values of X should be distinct.'
%
% does not sort data
% checks for duplicate values in xin
% returns xout where all values are distinct
%
% if duplicates found, separates values by small value (eps)
%
% input xin must be 1D
%
% useage:
% x = nonduplicate(x);
%
% yi = interp1(nonduplicate(x),y,xi)
%
% Example:
% interp1([1,1,2],[1,1,2],1.5)
% returns an error.
%
% interp1(nonduplicate([1,1,2]),[1,1,2],1.5)
% works just fine.
%
% written by Nathan Tomlin, nathan.a.tomlin@gmail.com
% v2: update 190321 after tip from Natalia Aziares Aguayo <n.aziares.a@gmail.com>
% same as listed here: https://stackoverflow.com/questions/13407030/desort-a-vector-undo-a-sorting
%
% should probably use consolidator instead

引用

Nathan Tomlin (2024). nonduplicate (https://www.mathworks.com/matlabcentral/fileexchange/26470-nonduplicate), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2007a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersArithmetic Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
2.0.0.0

Fixed problem so keeps correct order of input array.

1.0.0.0