nonduplicate

Makes all values of input array distinct - used to get interp1 to work when x data has duplicates.
1K téléchargements
Mise à jour 21 mars 2019

Afficher la licence

% 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

Citation pour cette source

Nathan Tomlin (2024). nonduplicate (https://www.mathworks.com/matlabcentral/fileexchange/26470-nonduplicate), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2007a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Arithmetic Operations dans Help Center et MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
2.0.0.0

Fixed problem so keeps correct order of input array.

1.0.0.0