0
votes

I was just about to find use for the ..., 'ForceCellOutput', true) name-value pair argument for the strfind command, as is described in the reference docs for strfind:

Syntax

k = strfind(str,pattern)
k = strfind(str,pattern,'ForceCellOutput',cellOutput))

...

Return Indices in Cell Array

Find the occurrences of a pattern in a character vector. Force strfind to return the indices of those occurrences in a cell array. Then display the indices.

Create a character vector and find the occurrences of the pattern ain.

str = 'The rain in Spain.';
k = strfind(str,'ain','ForceCellOutput',true)

The above does, however, yields an error for me (Error using strfind: Too many input arguments), and I noticed (after the error occurred) that the 2nd syntax above is not included in the native Matlab help, help strfind, for the version I'm running, R2015a.

I can't find any mention of this update, however, in the release notes for R2015b or R2016a.

  • Could someone verify that this optional syntax works for ver. > 2015a?
  • Is it common that minor (expanding/non-breaking) updates to Matlab commands are not included in the release notes? (Or have I've simply missed any mention regarding this one?)
1
Same here, I have the older version of 2010b. Maybe it was the 2015b version? - GameOfThrows
I'm going to guess R2015b, though strangely enough it's not in the "archived" R2015b documentation. - excaza
It may have been an undocumented addition in R2015b, it's present in the inline help for strfind but not in the documentation. It seems like the online documentation has shifted to R2016a already. - excaza
@excaza I see thanks. Didn't know you could access "archived" documentation online. Just a double-check: it works on R2015b? (which I assume, as it's in its inline help). - dfrib
Yes, your sample code functions in R2015b - excaza

1 Answers

1
votes

The sample code functions properly in R2015b but is not present in the documentation (requires login). It is, however, included in the inline documentation for strfind:

%   IND = STRFIND(TEXT,PATTERN,'ForceCellOutput',CELLOUTPUT) forces IND 
%   to be a cell array when CELLOUTPUT is true.

So it looks like it was an undocumented addition in R2015b. With the recent release of R2016a, the online documentation is now for R2016a, so they have documented the change moving forward.