Problem 76. De-dupe
Remove all the redundant elements in a vector, but keep the first occurrence of each value in its original location. So if
a = [5 3 6 4 7 7 3 5 9]
then
dedupe(a) = [5 3 6 4 7 9]
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
nhagen
on 18 Mar 2015
solved in one line !
nice problem
David Verrelli
on 7 Feb 2017
Hi, bainhome:
Cody is based on the 'current' version of MATLAB, not R2012b. Many functions are unchanged, but a few have changed (modified, new, or removed), including "unique".
You must add the 'legacy' flag to the list of arguments to preserve the behaviour of the "unique" function from R2012b and prior releases — refer to the documentation (link posted by Jakub Galecki).
—DIV
Hans Kramer
on 29 Jun 2018
if u know a specific function its too easy.
Solution Comments
Show commentsGroup

University of Leeds Cody Competition
- 50 Problems
- 7 Finishers
- Add two numbers
- Find the sum of all the numbers of the input vector
- Maximum value in a matrix
- Return area of square
- Finding Perfect Squares
- Make the vector [1 2 3 4 5 6 7 8 9 10]
- Generate a vector like 1,2,2,3,3,3,4,4,4,4
- Triangle Numbers
- Length of the hypotenuse
- Select every other element of a vector
- Column Removal
- Swap the input arguments
- Swap the first and last columns
- Check if number exists in vector
- Reverse the vector
- Determine whether a vector is monotonically increasing
- Getting the indices from a vector
- Create times-tables
- Return the first and last characters of a character array
- Number of 1s in a binary string
- Make a random, non-repeating vector.
- Magic is simple (for beginners)
- Sum all integers from 1 to 2^n
- Quote Doubler
- De-dupe
- Cell joiner
- Remove all the words that end with "ain"
- Nearest Numbers
- Find state names that start with the letter N
- Word Counting and Indexing
- Given two arrays, find the maximum overlap
- It dseon't mettar waht oedrr the lrettes in a wrod are.
- Counting in Finnish
- Create a figure and plot data
- Plotting Practice
- Jack O'Lantern
- 3D Plots and Colorbars
- Make a Plot with Functions
- Count the number of folds needed to pack a large sheet
- Characterize fluid flow in a pipe as to laminar or turbulent
- Create a matrix map of increasing safety levels
- Sum of Even Fibonacci Numbers
- Create the following sequence : 0 1 1 4 9 25 64 169 ...
- Battery Charge Efficiency Calculation
- Estimating Monthly Electricity Cost for a Household Appliance
- Pizza!
- Pi Digit Probability
- Roll the Dice!
- Triangle sequence
- Birthday cake
Problem Recent Solvers3441
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!