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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like