Conversion from char to cell is not possible
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Elakkiya Prakasam
am 17 Jul. 2017
Kommentiert: Elakkiya Prakasam
am 18 Jul. 2017
Hi I am trying to copy a cell array of strings to a cell array of cell arrays.
A = [8x3 char]
B = [8x1 double]
C = {8x2 cell}
C{1}(:,1) = A{1}; C{1}(:,2) = B{1};
how can i copy the strings in A cell to the first column of C cell and the integer data in B cell to 2nd column of C cell.
if i give like C{1}(:,1) = {A{1}};
A value is copied to all the rows in column 1 of C.
[8x3 char]
[8x3 char]
[8x3 char]
...
0 Kommentare
Akzeptierte Antwort
Guillaume
am 17 Jul. 2017
Bearbeitet: Guillaume
am 17 Jul. 2017
Despite your statement, A is not a cell array, but a 2D char array. You can convert A into a cell array of char vectors using cellstr. So:
C = [cellstr(A), num2str(B)]
would be the simplest way to obtain what you want.
Note: Since R2016b, string is a new type different from the char arrays you're using. To avoid ambiguity use the term char array (or vector) instead of string.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!