2

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
  • Does each cell contain one (scalar) string? I’m not sure why you are able to index with curly braces twice in that example, it doesn’t make sense to me. Could you please include a short script that generates something like your myCellArray? Just a few elements, not all 14k of them of course. Commented Oct 14, 2018 at 17:48
  • @CrisLuengo Sorry it was a typo. I fixed it. My cell array is generated by importing an excel worksheet as a cell array. its firs column is name of objects which are strings. Commented Oct 14, 2018 at 18:04

2 Answers 2

6

Try:

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

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

Source: Create String Arrays

Sign up to request clarification or add additional context in comments.

1 Comment

I have tested this already but I don't know what was wrong which did not work that time.
0

Use char command:

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

1 Comment

Here I use ( ) not { } for indexing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.