Search code examples
matlabcell-array

Matlab: How to convert cell array to string array?


I have a cell array sized 14676x117 call myCellArray. I want to extract values stored in myCellArray{2:14676,1} in an string array. runnning below script only returns a single string value and do not return an string array.

>> y= myCellArray{2:14676,1}
   y = 
      "test1"

How can I convert this cell array range to and string array?


Solution

  • Try:

    y = string(myCellArray{2:14675, 1})
    

    If you have MATLAB 2016b or newer, this should work.

    Source: Create String Arrays