From bug-request at octave dot org Sat Dec 31 11:41:03 2005 Subject: Support for cellstr argument in lower.m and upper.m From: William Poetra Yoga Hadisoeseno To: bug at octave dot org Date: Sun, 1 Jan 2006 01:39:29 +0800 ------=_Part_15797_12893407.1136050769183 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I've fixed the functions to make them compatible with their Matlab counterp= arts. -- William Poetra Yoga Hadisoeseno ------=_Part_15797_12893407.1136050769183 Content-Type: text/plain; name=str1.diff.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="str1.diff.txt" Index: scripts/strings/lower.m =================================================================== RCS file: /cvs/octave/scripts/strings/lower.m,v retrieving revision 1.6 diff -u -r1.6 lower.m --- scripts/strings/lower.m 26 Apr 2005 19:24:32 -0000 1.6 +++ scripts/strings/lower.m 31 Dec 2005 17:29:21 -0000 at @ -19,7 +19,8 @@ ## -*- texinfo -*- ## at deftypefn {Function File} {} lower (@var{s}) -## Transform all letters in the string at var{s} to lower case. +## Transform all letters in the string / cell array of strings at var{s} +## to lower case. ## at end deftypefn ## ## at seealso{tolower} at @ -32,6 +33,15 @@ usage ("lower (s)"); endif - retval = tolower (s); + if (ischar (s)) + retval = tolower (s); + elseif (iscellstr (s)) + retval = cell (size (s)); + for i = 1:(numel (s)) + retval{i} = tolower(s{i}); + endfor + else + error ("lower: `s' must be a string or cell array of strings"); + endif endfunction Index: scripts/strings/upper.m =================================================================== RCS file: /cvs/octave/scripts/strings/upper.m,v retrieving revision 1.6 diff -u -r1.6 upper.m --- scripts/strings/upper.m 26 Apr 2005 19:24:32 -0000 1.6 +++ scripts/strings/upper.m 31 Dec 2005 17:29:21 -0000 at @ -19,7 +19,8 @@ ## -*- texinfo -*- ## at deftypefn {Function File} {} upper (@var{s}) -## Transform all letters in the string at var{s} to upper case. +## Transform all letters in the string / cell array of strings at var{s} +## to upper case. ## at end deftypefn ## ## at seealso{toupper} at @ -32,6 +33,15 @@ usage ("upper (s)"); endif - retval = toupper (s); + if (ischar (s)) + retval = toupper (s); + elseif (iscellstr (s)) + retval = cell (size (s)); + for i = 1:(numel (s)) + retval{i} = toupper(s{i}); + endfor + else + error ("upper: `s' must be a string or cell array of strings"); + endif endfunction ------=_Part_15797_12893407.1136050769183 Content-Type: text/plain; name=str1.ChangeLog.txt; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="str1.ChangeLog.txt" 2006-01-01 William Poetra Yoga Hadisoeseno * strings/lower.m, strings/upper.m: Add support for cellstr arguments. ------=_Part_15797_12893407.1136050769183-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------