Commit 63430a54 authored by MichelJuillard's avatar MichelJuillard
Browse files

dynSeries: replacing strmatch by strcmp

parent 025f0d5b
...@@ -66,7 +66,7 @@ for i=1:nargin-1 ...@@ -66,7 +66,7 @@ for i=1:nargin-1
while ~isempty(expression) while ~isempty(expression)
[token, expression] = strtok(expression,','); [token, expression] = strtok(expression,',');
candidate = [VariableName(1:idArobase(1)-1), token, VariableName(idArobase(2)+1:end)]; candidate = [VariableName(1:idArobase(1)-1), token, VariableName(idArobase(2)+1:end)];
id = strmatch(candidate,B.name,'exact'); id = find(strcmp(candidate,B.name));
if isempty(id) if isempty(id)
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!']) error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
else else
...@@ -88,7 +88,7 @@ for i=1:nargin-1 ...@@ -88,7 +88,7 @@ for i=1:nargin-1
while ~isempty(expression_2) while ~isempty(expression_2)
[token_2, expression_2] = strtok(expression_2,','); [token_2, expression_2] = strtok(expression_2,',');
candidate = [VariableName(1:idArobase(1)-1), token_1, VariableName(idArobase(2)+1:idArobase(3)-1), token_2, VariableName(idArobase(4)+1:end)]; candidate = [VariableName(1:idArobase(1)-1), token_1, VariableName(idArobase(2)+1:idArobase(3)-1), token_2, VariableName(idArobase(4)+1:end)];
id = strmatch(candidate,B.name,'exact'); id = find(strcmp(candidate,B.name));
if isempty(id) if isempty(id)
error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!']) error(['dynSeries::extract: Variable ''' candidate ''' does not exist in dynSeries object ''' inputname(1) '''!'])
else else
...@@ -114,7 +114,7 @@ end ...@@ -114,7 +114,7 @@ end
% Get indices of the selected variables % Get indices of the selected variables
idVariableName = NaN(length(VariableName_),1); idVariableName = NaN(length(VariableName_),1);
for i = 1:length(idVariableName) for i = 1:length(idVariableName)
idx = strmatch(VariableName_{i},B.name,'exact'); idx = find(strcmp(VariableName_{i},B.name));
if isempty(idx) if isempty(idx)
error(['dynSeries::extract: Variable ' VariableName_{i} ' is not a member of ' inputname(1) '!']) error(['dynSeries::extract: Variable ' VariableName_{i} ' is not a member of ' inputname(1) '!'])
end end
......
...@@ -45,7 +45,7 @@ function [ts,id] = pop(ts,a) % --*-- Unitary tests --*-- ...@@ -45,7 +45,7 @@ function [ts,id] = pop(ts,a) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
id = strmatch(a,ts.name,'exact'); id = find(strcmp(a,ts.name));
if isempty(id) if isempty(id)
id = 0; id = 0;
return return
......
...@@ -21,7 +21,7 @@ if ~ischar(old) || ~ischar(new) ...@@ -21,7 +21,7 @@ if ~ischar(old) || ~ischar(new)
error(['dynSeries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!']) error(['dynSeries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!'])
end end
idname = strmatch(old,ts.name,'exact'); idname = find(strcmp(old,ts.name));
if isempty(idname) if isempty(idname)
error(['dynSeries::rename: Variable ' old ' is unknown in dynSeries object ' inputname(1) '!']) error(['dynSeries::rename: Variable ' old ' is unknown in dynSeries object ' inputname(1) '!'])
......
...@@ -84,7 +84,7 @@ switch length(S) ...@@ -84,7 +84,7 @@ switch length(S)
for i = 1:B.vobs for i = 1:B.vobs
if ~isequal(S(1).subs{i},B.name{i}) if ~isequal(S(1).subs{i},B.name{i})
% Rename a variable. % Rename a variable.
id = strmatch(S(1).subs{i},A.name); id = find(strcmp(S(1).subs{i},A.name));
if isempty(id) if isempty(id)
% Add a new variable a change its name. % Add a new variable a change its name.
B.name(i) = {S(1).subs{i}}; B.name(i) = {S(1).subs{i}};
...@@ -118,7 +118,7 @@ switch length(S) ...@@ -118,7 +118,7 @@ switch length(S)
% Single variable selection. % Single variable selection.
if ~isequal(S(1).subs,B.name{1}) if ~isequal(S(1).subs,B.name{1})
% Rename a variable. % Rename a variable.
id = strmatch(S(1).subs,A.name); id = find(strcmp(S(1).subs,A.name));
if isempty(id) if isempty(id)
% Add a new variable a change its name. % Add a new variable a change its name.
B.name(1) = {S(1).subs}; B.name(1) = {S(1).subs};
......
...@@ -139,7 +139,7 @@ switch S(1).type ...@@ -139,7 +139,7 @@ switch S(1).type
B = feval(S(1).subs,A,S(2).subs{:}); B = feval(S(1).subs,A,S(2).subs{:});
S = shiftS(S); S = shiftS(S);
otherwise % Extract a sub-object by selecting one variable. otherwise % Extract a sub-object by selecting one variable.
ndx = strmatch(S(1).subs,A.name,'exact'); ndx = find(strcmp(S(1).subs,A.name));
if ~isempty(ndx) if ~isempty(ndx)
B = dynSeries(); B = dynSeries();
B.data = A.data(:,ndx); B.data = A.data(:,ndx);
......
...@@ -32,7 +32,7 @@ assert(ischar(newtex), 'dynSeries::tex_rename: the newtex name must be a string' ...@@ -32,7 +32,7 @@ assert(ischar(newtex), 'dynSeries::tex_rename: the newtex name must be a string'
if nargin == 2 if nargin == 2
idname = 1; idname = 1;
else else
idname = strmatch(name, ts.name, 'exact'); idname = find(strcmp(name, ts.name));
if isempty(idname) if isempty(idname)
error(['dynSeries::tex_rename: Variable ' name ' is unknown in dynSeries object ' inputname(1) '!']) error(['dynSeries::tex_rename: Variable ' name ' is unknown in dynSeries object ' inputname(1) '!'])
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment