merge cell array

6 views (last 30 days)
Giovanni Nappi
Giovanni Nappi on 14 Jun 2012
Commented: Voss on 15 Aug 2023
Hi everybrody I have one column of text data (B) and one column of numerical data (A). I have to merge the two array in a unique dataset made of two columns (C). How can I do it?
simplified example: A=[0,1 0,2 0,3] B=[AT DE FR] C=[AT 0,1 DE 0,2 FR 0,3]
Thank you Giovanni
  1 Comment
the cyclist
the cyclist on 14 Jun 2012
This question would be clearer if you could use valid MATLAB syntax to indicate what A, B, and C look like.

Sign in to comment.

Answers (1)

Voss
Voss on 24 Jun 2023
Here's a guess
% "one column of numerical data":
A = {[0 1]; [0 2]; [0 3]}
A = 3×1 cell array
{[0 1]} {[0 2]} {[0 3]}
% "one column of text data":
B = {'AT'; 'DE'; 'FR'}
B = 3×1 cell array
{'AT'} {'DE'} {'FR'}
% merge to two columns:
C = [B A]
C = 3×2 cell array
{'AT'} {[0 1]} {'DE'} {[0 2]} {'FR'} {[0 3]}
  1 Comment
Voss
Voss on 15 Aug 2023
@Giovanni Nappi: Did this answer work for you?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!