This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Remove duplicates of any element from ordered lists

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




listlib::removeDupSorted(list) removes all duplicates of any element of the ordered list list.

listlib::removeDupSorted does the same as listlib::removeDuplicates, but it assumes that the list is sorted and, therefore, it is faster. A notable gain will only occur, if there are only few duplicates in a long list.


Example 1

listlib::removeDupSorted removes all duplicates from the given list:

listlib::removeDupSorted([1, 1, 1, 3, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7])

If the list is not ordered, listlib::removeDupSorted fails:

listlib::removeDupSorted([1, 3, 5, 7, 1, 3, 5, 7, 1, 3, 5, 7])



An ordered MuPAD® list

Return Values

List that contains every element only once

See Also

MuPAD Functions

Was this topic helpful?