Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sébastien Villemot
dseries
Commits
5ad19f2b
Commit
5ad19f2b
authored
Oct 21, 2015
by
Houtan Bastani
Browse files
add batch rename
(cherry picked from commit
f4d6dd72
)
parent
95661afb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/@dseries/rename.m
View file @
5ad19f2b
function
ts
=
rename
(
ts
,
old
,
new
)
% --*-- Unitary tests --*--
% Copyright (C) 2013 Dynare Team
% Copyright (C) 2013
-2015
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -22,13 +22,15 @@ if isempty(ts)
end
if
nargin
<
3
if
isequal
(
vobs
(
ts
),
1
)
if
isequal
(
vobs
(
ts
),
1
)
||
isequal
(
vobs
(
ts
),
length
(
old
))
new
=
old
;
else
error
(
'dseries::rename: Missing argument!'
)
end
if
~
ischar
(
new
)
error
([
'dseries::rename: Input argument
''
'
inputname
(
2
)
'
''
has to be a string!'
])
if
~
ischar
(
new
)
&&
~
(
iscellstr
(
new
)
&&
isequal
(
vobs
(
ts
),
length
(
new
)))
error
([
'dseries::rename: Input argument
''
'
...
inputname
(
2
)
...
'
''
has to be either a string or a cellstring that has the same number of entries as observed variables!'
])
end
idname
=
1
;
else
...
...
@@ -41,7 +43,11 @@ else
end
end
ts
.
name
(
idname
)
=
{
new
};
if
iscellstr
(
new
)
ts
.
name
=
new
;
else
ts
.
name
(
idname
)
=
{
new
};
end
%@test:1
%$ t = zeros(8,1);
...
...
@@ -105,3 +111,20 @@ ts.name(idname) = {new};
%$
%$ T = all(t);
%@eof:3
%@test:4
%$ t = zeros(2,1);
%$ ts = dseries(randn(10,3));
%$ try
%$ ts = ts.rename({'Dora', 'The', 'Explorer'});
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dassert(ts.name, {'Dora', 'The', 'Explorer'});
%$ end
%$
%$ T = all(t);
%@eof:4
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment