Combining two cell arrays into one cell array changes format

2 views (last 30 days)
Hello,
I would like to combine two cell arrays into one, such that the second array shows up as the last column in the first array. The first one (A) is a 129102x144 cell array, and the second one (B) is a 129102x1 cell array.
I tried using
C=cat(2,A,B) or C=horzcat(A,B)
Both of them work, but in the resulting array C, all the elements of A become characters with apostrophes, eg. before: A{1,1} = 1190898 after: C{1,1} = '1190898' . However, the elements of array B don't have the apostrophes. Before: B{1,1} = 22 and after: C{1,145} = 22.
Could anyone please explain why this is the case and what should I do to combine the two cell arrays A and B but get rid of the apostrophes?
Thank you very much for your help!

Accepted Answer

Image Analyst
Image Analyst on 1 Feb 2014
What if you try
C = A; % Initialize
C(:,end+1) = B; % Tack on B.
What does this report:
whos A{1,1}
whos C{1,1}
  6 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!