Trim leading/trailing repeated values

Numeric vector/2D matrix. Trims leading, trailing or both sides; operates columnwise or row-wise.
464 Downloads
Aktualisiert 4. Sep 2013

Lizenz anzeigen

Trims leading/trailing repeated values of a series of numbers

TRIMREPLT(IN) Single input syntax
- In : numeric vector/2D matrix

TRIMREPLT(IN, DIM) Trims along the dimension specified by dim
- dim : scalar, numeric and integer value (or empty)
1 --> trims columnwise (DEFAULT)
2 --> trims row-wise

TRIMREPLT(IN, DIM, MODE) Which side to trim
- mode : char (or empty)
'l' --> trim leading repeated values
't' --> trim trailing repeated values (DEFAULT)
'lt'--> trim both sides

OUT = ...
- Same class/size as In. Leading/trailing repeated values (according to 'mode' argument)
are replaced with NaN values.
Given a vector IN and MODE = 't', IN(x+1) is considered a repeated value of IN(x) only
if IN(x+1:end) == NANMEAN(IN(x+1:end)).
The value IN(x) will be left unchanged.

See attahced image for examples.

Comments/suggestions/error reports are welcome.

p6v2

Zitieren als

Oleg Komarov (2024). Trim leading/trailing repeated values (https://www.mathworks.com/matlabcentral/fileexchange/26241-trim-leading-trailing-repeated-values), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2009b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Project Setup 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
1.2.0.0

Added forward 'legacy' compatibility due to change in ismember behaviour.

1.1.0.0

Added link to FEX page inside the help

1.0.0.0