Converting cells to strings
Mostrar comentarios más antiguos
Actually I have a 1x1 struct that I am extracting data from.
But the data is a mixture of numbers and strings.
I want to convert all of the data into strings so that I could store it in a separate cell array.
'char' doesn't do a good conversion, because it truncates everything to 255.
Respuesta aceptada
Más respuestas (3)
Jan
el 15 de Abr. de 2011
Are the numbers scalars or arrays? Which format do you want as output?
C = struct2cell(DataStruct);
numIndex = find(not(cellfun('isclass', C, 'char')));
for i = reshape(numIndex, 1, [])
C{i} = numstr(C{i});
end
Walter Roberson
el 15 de Abr. de 2011
0 votos
Which MATLAB version are you using? char() has accepted up to 65535 since approximately MATLAB 6.2.
1 comentario
Jan
el 15 de Abr. de 2011
Even MATLAB 5.3 had 16 bit CHARs already.
John Brathwaite
el 18 de Abr. de 2011
0 votos
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!