From: <par...@us...> - 2010-10-16 23:54:25
|
Revision: 7854 http://octave.svn.sourceforge.net/octave/?rev=7854&view=rev Author: paramaniac Date: 2010-10-16 23:54:18 +0000 (Sat, 16 Oct 2010) Log Message: ----------- control: improve check for label names Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/set.m trunk/octave-forge/main/control/inst/@ss/__set__.m Added Paths: ----------- trunk/octave-forge/main/control/inst/__adjust_labels__.m Removed Paths: ------------- trunk/octave-forge/main/control/inst/__check_name_numel__.m Modified: trunk/octave-forge/main/control/inst/@lti/set.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/set.m 2010-10-16 23:10:35 UTC (rev 7853) +++ trunk/octave-forge/main/control/inst/@lti/set.m 2010-10-16 23:54:18 UTC (rev 7854) @@ -60,10 +60,10 @@ switch (prop) case {"inname", "inputname"} - sys.inname = __check_name_numel__ (val, m); + sys.inname = __adjust_labels__ (val, m); case {"outname", "outputname"} - sys.outname = __check_name_numel__ (val, p); + sys.outname = __adjust_labels__ (val, p); case {"tsam", "ts"} if (issample (val)) Modified: trunk/octave-forge/main/control/inst/@ss/__set__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__set__.m 2010-10-16 23:10:35 UTC (rev 7853) +++ trunk/octave-forge/main/control/inst/@ss/__set__.m 2010-10-16 23:54:18 UTC (rev 7854) @@ -51,7 +51,7 @@ case {"stname", "statename"} n = rows (sys.a); - sys.stname = __check_name_numel__ (val, n); + sys.stname = __adjust_labels__ (val, n); otherwise error ("ss: set: invalid property name"); Added: trunk/octave-forge/main/control/inst/__adjust_labels__.m =================================================================== --- trunk/octave-forge/main/control/inst/__adjust_labels__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__adjust_labels__.m 2010-10-16 23:54:18 UTC (rev 7854) @@ -0,0 +1,38 @@ +## Copyright (C) 2009, 2010 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Check whether a cell contains the required number of strings. +## Used by set and __set__. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.3 + +function name = __adjust_labels__ (name, req_len) + + if (iscell (name)) + name = reshape (name, [], 1); + else # catch the siso case, + name = {name}; # e.g. sys = set (sys, "inname", "u_1") + endif + + if (! iscellstr (name) || numel (name) != req_len) + error ("lti: set: cell must contain %d strings", req_len); + endif + +endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/__check_name_numel__.m =================================================================== --- trunk/octave-forge/main/control/inst/__check_name_numel__.m 2010-10-16 23:10:35 UTC (rev 7853) +++ trunk/octave-forge/main/control/inst/__check_name_numel__.m 2010-10-16 23:54:18 UTC (rev 7854) @@ -1,38 +0,0 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Check whether a cell contains the required number of strings. -## Used by set and __set__. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.2 - -function name = __check_name_numel__ (name, req_len) - - if (! iscell (name)) # catch the siso case, - name = {name}; # e.g. sys = set (sys, "inname", "u_1") - endif - - name = reshape (name, [], 1); - - if (numel (name) != req_len) - error ("lti: set: cell must contain %d strings", req_len); - endif - -endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |