MATLAB: How to concat the cell matrix (containing text) to numeric array

cell arraysmatrixmatrix arraystrings

i have two matrix A = size(20*1) containing number rr matrix containing True' or 'False'
if(A(i)<1)
rr{i}=['True'];
else
rr{i}=['False'];
end
i wanted to concate these two matrix such that
A
0.8 True
1 False
....
and so on
A= horzcat(A,rr')
i got the following error
Error using horzcat
CAT arguments dimensions are not consistent.
Error in sv
A= horzcat(A,rr')

Best Answer

Perhaps simply merging the data into one cell array:
>> A = [0.8; 1];
>> rr = {'True', 'False'};
>> C = num2cell(A);
>> C(:,2) = rr
C =
[0.8] 'True'
[ 1] 'False'
Note that because these numeric and char arrays are in a cell array they will be displayed with their own array markers, [] for numeric arrays and '' for char arrays.
If you want to print the data without those markers, then you can use fprintf:
>> D = num2cell(A');
>> D(2,:) = rr;
>> fprintf(' %-10g %s\n',D{:})
0.8 True
1 False