0

any idea why this isn't returning true???

comments01a is a cell array of cells although I'd be perfectly happy converting it to a matrix. However, cell2mat(comments01a) gives its own error that it doesn't support cell arrays containing cell arrays or objects (which this one does) and I don't know of any alternatives.

comments01a{1}

ans = '4'

isequal(comments01a{1}, '4')

ans = 0

1 Answers1

2

Because '4', in this case, is a cell containing the string '4'. So, isequal is comparing a cell to a string. The solution is either this:

strcmp(comments01a{1}, '4')

Or maybe this, if you've actually nested cells in cells, as your question suggests:

strcmp(comments01a{1}{1}, '4')

If neither of these do it, you can try this, which replaces the '4' string with the number:

isequal(comments01a{1}{1}, 4)

Hope this helps. Let me know if it doesn't, and I'll take another shot at it.

Justin Fletcher
  • 2,319
  • 2
  • 17
  • 32