How to reshape an array horizontally
22 ビュー (過去 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 件のコメント
Star Strider
2020 年 9 月 22 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
その他の回答 (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 で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!