nonduplicate

Makes all values of input array distinct - used to get interp1 to work when x data has duplicates.
1K Downloads
Aktualisiert 21 Mär 2019

Lizenz anzeigen

% 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

Zitieren als

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

Kompatibilität der MATLAB-Version
Erstellt mit R2007a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Arithmetic Operations finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
2.0.0.0

Fixed problem so keeps correct order of input array.

1.0.0.0