Cell Arrays to string
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
If I have a long cell array, say a 1x120 cell (its arbitrary), each containing a different word like 'the' in one, and 'or' in the next. How can I combine the entire thing into one long string if possible?
0 comentarios
Respuestas (1)
  MKN
 el 24 de Feb. de 2015
        
      Editada: per isakson
      
      
 el 24 de Feb. de 2015
  
      cellData = {'Matlab','is','a','high','level','programming','language'}; % Cell array
combinedString = [];
for i = 1:length(cellData)
     combinedString = [combinedString cellData{i}]; % string
end
combinedString  % display string
2 comentarios
  per isakson
      
      
 el 24 de Feb. de 2015
				
      Editada: per isakson
      
      
 el 24 de Feb. de 2015
  
			shorter
    >> str = strjoin( cellData, ' ' )
    str =
    Matlab is a high level programming language
without space
    >> str = strjoin( cellData, '' )
    str =
    Matlabisahighlevelprogramminglanguage
Ver también
Categorías
				Más información sobre Characters and Strings en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



