Problem 43181. Find index of a string in a cell array

Solution 2991901

Submitted on 25 Sep 2020 by Benjamin
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
x = {'twenty-one'; 'twenty-two'; 'twenty-three'; 'one'; 'two'; 'three'}; for i = 1:6 assert(isequal(cellfind(x{i}, x),i)) validatestring(x{cellfind(x{i}, x)}, {x{i}}) end

ans = 'twenty-one' ans = 'twenty-two' ans = 'twenty-three' ans = 'one' ans = 'two' ans = 'three'

Suggested Problems

More from this Author15

Community Treasure Hunt

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

Start Hunting!