MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Write a function to get unique elements of a vector faster than unique()! Input will be a vector (of integers or floating point numbers) of any size. The order of the returned vector is unimportant.

Example: Input: x = [1 1 2 2 3 3]; Output: [1 2 3];

Input: x = [0.1 3.1 2.1 2.0 3.1]; Output: [0.1 3.1 2.1 2.0]; % or any order

56 correct solutions
110 incorrect solutions

Last solution submitted on Mar 21, 2015

1 player likes this solution

3 Comments

Boris Huart
on 1 Feb 2013

It was too tempting...

James
on 1 Feb 2013

I thought I was being original by trying this. Guess not... :-(

Jeremy
on 3 Feb 2013

Clever :), hadn't thought of that!

1 Comment

Jeremy
on 1 Feb 2013

thanks for the hint!

5 Comments