#141: Replace strmatch which is a deprecated function in Matlab --------------------------+------------------------------------------------- Reporter: houtanb | Owner: Type: bug | Status: new Priority: major | Milestone: Component: Core M-files | Version: Keywords: | --------------------------+------------------------------------------------- Use strncmp instead, which has a different return type
http://www.mathworks.com/help/techdoc/ref/strmatch.html
#141: Replace strmatch which is a deprecated function in Matlab ---------------------------+------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: major | Milestone: 4.2 Component: Core M-files | Version: Resolution: | Keywords: ---------------------------+------------------------------------------------ Changes (by houtanb):
* milestone: => 4.2
#141: Replace strmatch which is a deprecated function in Matlab ---------------------------+------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: trivial | Milestone: Component: Core M-files | Version: Resolution: | Keywords: ---------------------------+------------------------------------------------ Changes (by houtanb):
* priority: major => trivial * milestone: 4.2 =>
Comment:
The solution to this problem will come in several parts:
1) Developers must stop using strmatch 2) Developers should replace instances of strmatch with strncmp in code that they know well 3) When Matlab finally removes support for strmatch, it should be coded up and placed in ~/dynare/matlab/missing/strmatch
#141: Replace strmatch which is a deprecated function in Matlab ---------------------------+------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: trivial | Milestone: 4.3 Component: Core M-files | Version: Resolution: | Keywords: ---------------------------+------------------------------------------------ Changes (by sebastien):
* milestone: => 4.3
#141: Replace strmatch which is a deprecated function in Matlab ---------------------+------------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: trivial | Milestone: 4.3 Component: General | Version: Keywords: | ---------------------+------------------------------------------------------
Comment(by jpfeifer):
Replying to [ticket:141 houtanb]:
Use strncmp instead, which has a different return type
strmatch should be replaced by find(strcmp()) which replicates the behavior of strmatch and avoids sprecifying the string length, which would be required if one uses strncmp (note the n).
#141: Replace strmatch which is a deprecated function in Matlab ---------------------+------------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: trivial | Milestone: 4.3 Component: General | Version: Keywords: | ---------------------+------------------------------------------------------
Comment(by jpfeifer):
Unfortunately, strmatch ignored trailing whitespaces, while strcmp considers them. Apparently, the only way is to replace e.g.
strmatch(var_list_(i,:),M_.endo_names)
with
n=length(var_list_(i,:)); find(strncmp(var_list_(i,:),M_.endo_names,n))
#141: Replace strmatch which is a deprecated function in Matlab ---------------------+------------------------------------------------------ Reporter: houtanb | Owner: Type: bug | Status: new Priority: trivial | Milestone: 5.0 Component: General | Version: Keywords: | ---------------------+------------------------------------------------------ Changes (by sebastien):
* milestone: 4.3 => 5.0
Comment:
Note that strncmp only accept cell arrays, not string arrays. So one has to convert M_.endo_names to a cell array with cellstr. Also, strncmp considers trailing whitespace.
The safe equivalent of:
strmatch(var_list_(i,:),M_.endo_names)
is therefore:
n = length(strtrim(var_list_(i,:)); find(strncmp(strtrim(var_list_(i,:)), cellstr(M_.endo_names), n);
Maybe we should consider switching to cell arrays instead of string arrays for M_.*_names.
#141: Replace strmatch which is a deprecated function in Matlab ----------------------+-------------------- Reporter: houtanb | Owner: Type: bug | Status: closed Priority: trivial | Milestone: 5.0 Component: General | Version: Resolution: wontfix | Keywords: ----------------------+-------------------- Changes (by sebastien):
* status: new => closed * resolution: => wontfix
Comment:
Closing, since it looks like MATLAB no longer plans to remove that function (even though its usage is not recommended)