Numeric array to cell array of strings (easy) - MATLAB Cody - MATLAB Central

Problem 1741. Numeric array to cell array of strings (easy)

Difficulty:Rate

Given a numeric array (A) and a 1xk cell array of strings (C), return a cell array (B) that is the same size as A and in which each element of B is the string in C indexed by the same element in A.

You may assume that every element of A is an integer on the interval [1,k].

Example

If

A = [1 2 3
     2 3 1
     3 1 2];
C = {'yes','no','maybe'};

Then

B = {'yes'    'no'     'maybe'
     'no'     'maybe'  'yes'
     'maybe'  'yes'    'no'};

Solution Stats

57.39% Correct | 42.61% Incorrect
Last Solution submitted on Jun 25, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
4

Problem Recent Solvers58

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!