cell array to char array?

575 visualizaciones (últimos 30 días)
raktim banerjee
raktim banerjee el 26 de En. de 2011
Comentada: Hary el 31 de Mzo. de 2023
Hello Sir!
How to convert a cell array to char array? I want to read 2 strings from a .txt file and want them in char type. if I do as follow those are cell type. The file contains 2 strings in 1st line, separated by a single space.
[a,b] = textread('inp.txt','%s%s',1)

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de En. de 2011
char(a) and char(b)
  4 comentarios
raktim banerjee
raktim banerjee el 26 de En. de 2011
Tank you sir!
Hary
Hary el 31 de Mzo. de 2023
alternatively,
>> a = {'9a','abc'}
a =
1×2 cell array
{'9a'} {'abc'}
>> a{1}
ans =
'9a'

Iniciar sesión para comentar.

Más respuestas (1)

piyari sadia
piyari sadia el 17 de Ag. de 2011
letters_lut ='AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890'; HOW (letters_lut) is used to convert the cell array to a character?
  1 comentario
Walter Roberson
Walter Roberson el 17 de Ag. de 2011
Please expand on your question. Conversion from cell array to character string is a matter of de-referencing each of the cell array entries to get the already-contained character string, and building up rows of a char array, with the rows padded (with blanks) to the length of the longest string. There is no look-up table involved in the process.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by