How to reshape an array horizontally
    11 次查看(过去 30 天)
  
       显示 更早的评论
    
I wanted to know how to go about reshaping a character array horizontally, starting from the first index in the first row, and then the second and so on. So I want to change:
text =
  3×5 char array
    'words'
    'words'
    'words'
Into
text =
1x15 char array
'wordswordswords'
How do I do this?
0 个评论
采纳的回答
  Star Strider
      
      
 2020-9-22
        text1 = ['words'; 'words'; 'words']
text2 = reshape(text1', 1, [])
producing: 
text1 =
  3×5 char array
    'words'
    'words'
    'words'
text2 =
    'wordswordswords'
.
6 个评论
更多回答(1 个)
  Jérôme
 2024-4-22
        I know it's not the class used in que question, but it's just to share how to do it with strings.
In case a string array is used instead of a char array, this can be done with the function strjoin:
text_1 = ["words" ; "words" ; "words"]
text_2 = strjoin(text_1, "")
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



