Hello,
I am facing a Matlab compatability issue regarding the contains function. I wrote a script using Matlab 2017b but want to give it to a user group who only has access to 2014b.
The main back-compatability issue is that I use the contains function to find all indices of a text-based cell vector matching a string (e.g. indices = contains(cellVec, 'string')). I then reduce a different but identically-sized cell vector using those indices (e.g. cellVec2 = cellVec2(indices)). This was working very effectively for my needs and avoids any loops. Unfortunately, I need to find a way to replace all of these contains calls - I looked into using indices = ~isempty(strfind(cellVec,'string')) but this yields a single result instead of a numeric vector of results.
Since my computer has 2014b and 2017b, is there anything I can do to poach the 2017b contains function in a way that is usable by 2014b, or can I use strfind or another function to produce a numeric vector of indices while avoiding loops?
Thanks, Charlie
2 Comments
Walter Roberson (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/494933-can-i-move-the-contains-function-from-matlab-2017b-to-matlab-2014b#comment_774596
Adam Danz (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/494933-can-i-move-the-contains-function-from-matlab-2017b-to-matlab-2014b#comment_774671
Sign in to comment.