Cody

# Problem 980. Unique values without using UNIQUE function

Solution 3197891

Submitted on 13 Oct 2020 by ivan fernandez
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 y = your_fcn_name(x) unico = [x(1)]; lunx = length(x) for i = 2 : lunx sameV = false; for j = 1:length(unico) if x(i) == unico(j) sameV = true break end end if sameV ~= true unico = [unico x(i)] end end y = unico end %This code written by profile_id 7996678 ' lunx = 4 unico = 9 2 sameV = logical 1 unico = 9 2 5 y = 9 2 5

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

lunx = 7 unico = 42 1 sameV = logical 1 sameV = logical 1 sameV = logical 1 unico = 42 1 17 sameV = logical 1 y = 42 1 17

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

lunx = 25 unico = 0.3455 0.2680 unico = 0.3455 0.2680 0.8510 unico = 0.3455 0.2680 0.8510 0.9319 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 unico = 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Column 18 0.3550 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 19 0.3550 0.2209 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 20 0.3550 0.2209 0.0583 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 21 0.3550 0.2209 0.0583 0.4747 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 22 0.3550 0.2209 0.0583 0.4747 0.6538 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 23 0.3550 0.2209 0.0583 0.4747 0.6538 0.6824 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 24 0.3550 0.2209 0.0583 0.4747 0.6538 0.6824 0.5216 unico = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 25 0.3550 0.2209 0.0583 0.4747 0.6538 0.6824 0.5216 0.5146 y = Columns 1 through 17 0.3455 0.2680 0.8510 0.9319 0.1926 0.0173 0.0776 0.7597 0.5356 0.0498 0.0692 0.0426 0.1969 0.7403 0.0366 0.3591 0.5127 Columns 18 through 25 0.3550 0.2209 0.0583 0.4747 0.6538 0.6824 0.5216 0.5146

### Community Treasure Hunt

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

Start Hunting!