Cody

Problem 1973. Reassign cell contents to empty variables, preserving cell content data type

Solution 528903

Submitted on 14 Nov 2014
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
%% C = {1}; D_correct = {[]}; assert(isequal(resetCell(C), D_correct))

2   Fail
%% C = {1, 2; zeros(2, 'single'), 'ABC'}; D_correct = { [], []; zeros(0, 'single'), '' }; assert(isequal(resetCell(C), D_correct))

Error: Input following 'like' is not a numeric array.

3   Fail
%% C = {true, rand(2), 'MATLAB'}; D_correct = {true(0), [], ''}; assert(isequal(resetCell(C), D_correct))

Error: Input following 'like' is not a numeric array.

4   Fail
%% C = {1, 2, 'ABC'; true, struct('A', 1), {0}}; D_correct = {[], [], ''; true(0), struct([]), {}}; assert(isequal(resetCell(C), D_correct))

Error: Input following 'like' is not a numeric array.

5   Fail
%% C = {1, single(3), @sin}; D_correct = {[], single([]), function_handle.empty}; assert(isequal(resetCell(C), D_correct))

Error: Input following 'like' is not a numeric array.

6   Pass
%% C = {uint8(1), zeros(2, 'int16'), []}; D_correct = {zeros(0, 'uint8'), zeros(0, 'int16'), []}; assert(isequal(resetCell(C), D_correct))