Cody

# Problem 980. Unique values without using UNIQUE function

Solution 2990059

Submitted on 25 Sep 2020 by Jeremy Perez
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'unique'))) assert(isempty(strfind(filetext, 'stable'))) A = [9 2 9 5]; assert(isequal(your_fcn_name(A),unique(A,'stable')))

filetext = 'function ans = your_fcn_name(x) x(arrayfun(@(k) ~ismember(x(k), x(1:k-1)), 1:(length(x)))) end %This code written by profile_id 15999310 ' ans = 9 2 5

2   Pass
x = [42 1 1 1 42 17 17]; assert(isequal(your_fcn_name(x),unique(x,'stable')))

ans = 42 1 17

3   Pass
x = rand(1,25); assert(isequal(your_fcn_name(x),unique(x,'stable')))

ans = Columns 1 through 17 0.8087 0.5338 0.1776 0.9528 0.2759 0.3599 0.4503 0.0236 0.6943 0.1633 0.2952 0.3112 0.0221 0.3150 0.3729 0.2148 0.4378 Columns 18 through 25 0.9150 0.5530 0.2653 0.1923 0.2982 0.5866 0.5967 0.8798

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!