# Problem 1899. Convert a Cell Array into an Array

Mayla on 19 Sep 2023

Given a square cell array:
x = {'01', '56'; '234', '789'};
return a single character array:
y = '0123456789'
I wrote a code that passes Test 1 and 2 and one that passes Test 3 but I'm searching a condition so that the code for Test 3 runs when the cell array only contains letters and the one for Test 1 and 2 in every other case. Can somebody help me?
This is my code:
y = []
[a,b]=size(x)
%%TEST 3
delimiter=zeros(1,a)
delimiter(end)=1
delimiter=repmat(delimiter,1,b)
delimiter(end)=''
delimiter=string(delimiter)
y=[]
for i=1:a*b
y = string([y x(i)])
end
y=join(y,delimiter)
y=erase(y,'0')
y=regexprep(y,'1',' ')
%%TEST 1+2
for i=1:a*b
y = string([y x(i)])
y=join(y)
end
y=erase(y,' ' )

Adam Danz on 19 Sep 2023
I didn't want to give away a cody solution ;)
Dyuman Joshi on 19 Sep 2023
Matt J on 19 Sep 2023
x = {'01', '56'; '234', '789'};
y=[x{:}]
y = '0123456789'
x={'' 'a' '1'; 'AA' 'BB' 'CC'; 'dog' 'cat' 'car'};
y=[x{:}]
x={'We' 'do' ;'ll ' 'ne.'};
y=[x{:}]
y = 'Well done.'
Adam Danz on 19 Sep 2023
Ahhh I see. Thanks @Dyuman Joshi!
Dyuman Joshi on 19 Sep 2023
@Adam Danz, OP is talking about Cody Problem 1899 - Convert a Cell Array into an Array. Here are the test cases for that problem, inputs and expected outputs -
%%
x={'01', '56'; '234', '789'};
y_correct = '0123456789';
%%
x={'' 'a' '1'; 'AA' 'BB' 'CC'; 'dog' 'cat' 'car'};