Matlab: How to convert cell array to string array?

大城市里の小女人 提交于 2021-01-28 10:53:10

问题


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?


回答1:


Try:

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

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

Source: Create String Arrays




回答2:


Use char command:

c = char(myCellArray(2:14675, 1))



来源:https://stackoverflow.com/questions/52805061/matlab-how-to-convert-cell-array-to-string-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!