Combining a text (cell) vector with a number (double) vector...?

2 Ansichten (letzte 30 Tage)
Aaron
Aaron am 27 Aug. 2012
I have two 3504x1 vectors that I need to combine to have one matrix with two columns, where the first column is one of my two vectors and the second column is the other. One vector is made up of text/cell data (e.g. "1580X-V 12.47") and one is "double" type (numbers).
When I try:
C = [A; B]
It just returns A to me...
Please help!
Thanks! Aaron

Antworten (1)

Sean de Wolski
Sean de Wolski am 27 Aug. 2012
If you have the Statistics Toolbox, you can use the dataset class for this:
c = cellstr(('helloworld')')
x = (1:10)';
DS = dataset(c,x,'VarNames',{'CellData','NumericData'})
Else just call num2cell on your numeric data.
  1 Kommentar
Walter Roberson
Walter Roberson am 27 Aug. 2012
In particular, [A, num2cell(B)]
Notice I used comma rather than semi-colon, as you want two columns.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by