MATLAB: How to reshape an array horizontally

arraysMATLAB

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?

Best Answer

  • Using the reshape function:
    text1 = ['words'; 'words'; 'words']
    text2 = reshape(text1', 1, [])
    producing:
    text1 =
    3×5 char array
    'words'
    'words'
    'words'
    text2 =
    'wordswordswords'
    .