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

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Solution 199295

Submitted on 1 Feb 2013 by Jeremy

Correct

25Size
Leading solution size is 10.
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
x = rand(10000, 1);
z = rand(10000, 1);
x = vertcat(x, z);
tic
y_correct = unique(x);
t_unique = toc
tic
y_myunique = my_unique(x);
t_myunique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_myunique)
```
```t_unique =
0.0266
t_myunique =
0.0030
```
2
Pass

```%%
x = rand(50000, 1);
z = rand(50000, 1);
x = vertcat(x, z);
tic
y_correct = unique(x);
t_unique = toc
tic
y_my_unique = my_unique(x);
t_my_unique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_my_unique)
```
```t_unique =
0.0126
t_my_unique =
0.0117
```
3
Pass

```%%
x = [1; 2; 3; 4; 2; 3; 4; 5;];
tic
y_correct = unique(x);
t_unique = toc
tic
y_my_unique = my_unique(x);
t_my_unique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_my_unique)
```
```t_unique =
1.7200e-04
t_my_unique =
4.5000e-05
```