Matlab: How to Convert Cell Array to String 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?

2

2 Answers

Try:

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

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

Source: Create String Arrays

1

Use char command:

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.