Commit ee49426f authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added the possibility to call rename method with one argument if dseries

object contains only one variable.

Also check that the dseries object is not empty.
parent 58f75327
......@@ -17,14 +17,28 @@ function ts = rename(ts,old,new) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ~ischar(old) || ~ischar(new)
error(['dseries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!'])
if isempty(ts)
error('dseries::rename: Cannot rename variable(s) because the object is empty!')
end
idname = find(strcmp(old,ts.name));
if isempty(idname)
error(['dseries::rename: Variable ' old ' is unknown in dseries object ' inputname(1) '!'])
if nargin<3
if isequal(vobs(ts), 1)
new = old;
else
error('dseries::rename: Missing argument!')
end
if ~ischar(new)
error(['dseries::rename: Input argument ''' inputname(2) ''' has to be a string!'])
end
idname = 1;
else
if ~ischar(old) || ~ischar(new)
error(['dseries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) ''' have to be strings!'])
end
idname = find(strcmp(old,ts.name));
if isempty(idname)
error(['dseries::rename: Variable ' old ' is unknown in dseries object ' inputname(1) '!'])
end
end
ts.name(idname) = {new};
......
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