Cody

Problem 43673. String Array Basics, Part 4: Convert String Array with Missing Values to Cell Array

Solution 3025960

Submitted on 2 Oct 2020 by Augusto Mazzei
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 = string({'I','love','MATLAB'}); y_correct = {'I','love','MATLAB'}; assert(isequal(str2cell(x),y_correct))

x = 1×3 string array "I" "love" "MATLAB"

2   Pass
x = string({'I','love'}); x(5) = 'MATLAB'; y_correct = {'I','love','','','MATLAB'}; assert(isequal(str2cell(x),y_correct))

x = 1×5 string array "I" "love" "" "" "MATLAB"

3   Pass
x = string([1 NaN 2]); y_correct = {'1','','2'}; assert(isequal(str2cell(x),y_correct))

x = 1×3 string array "1" "" "2"

4   Pass
x = strings(3); x(1) = 'first'; x(end) = 'last'; y_correct = {'first', '', '' '', '', '' '', '', 'last'}; assert(isequal(str2cell(x),y_correct))

x = 3×3 string array "first" "" "" "" "" "" "" "" "last"