Skip to content
Snippets Groups Projects
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
Branches
No related tags found
No related merge requests found
......@@ -17,15 +17,29 @@ 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 isempty(ts)
error('dseries::rename: Cannot rename variable(s) because the object is empty!')
end
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};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment