nonduplicate
% 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
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
2.0.0.0 | Fixed problem so keeps correct order of input array. |
||
1.0.0.0 |