From bug-octave-request at che dot utexas dot edu Sat May 21 23:26:58 1994 Subject: int2str.m From: Ken Neighbors To: bug-octave at che dot utexas dot edu (Octave Bug) Date: Sat, 21 May 1994 21:26:47 -0700 (PDT) I'm running Octave 1.0 under Linux 0.99.15 #1 Thu Feb 3 19:55:32 CST 1994 from Slackware 1.1.2 on my 486DX33. (In my ongoing quest to get the MATLAB controls toolbox to run under Octave) int2str was not returning results compatible with MATLAB's int2str. Specifically, it should return an integer with no decimal point and zeros, e.g., int2str(2.3) should be "2" instead of "2.000000". I fixed this. The modified int2str.m is below. Ken Neighbors wkn at leland dot stanford dot edu Originally: *************** beginning of log ***************** Octave, version 1.0. Copyright (C) 1992, 1993, 1994 John W. Eaton. This is free software with ABSOLUTELY NO WARRANTY. For details, type `warranty'. octave:1> int2str(2.3) ans = 2.000000 octave:2> ['A' int2str(2.3) 'B'] ans = A2.000000 B octave:3> *************** end of log ***************** Fixed: *************** beginning of log ***************** Octave, version 1.0. Copyright (C) 1992, 1993, 1994 John W. Eaton. This is free software with ABSOLUTELY NO WARRANTY. For details, type `warranty'. octave:1> int2str(2.3) ans = 2 octave:2> ['A' int2str(2.3) 'B'] ans = A2B octave:3> *************** end of log ***************** *************** beginning of int2str.m ***************** # Copyright (C) 1993 John W. Eaton # # This file is part of Octave. # # Octave 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 2, or (at your option) any # later version. # # Octave 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 Octave; see the file COPYING. If not, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. function retval = int2str (x) # usage: int2str (x) # # Round x to the nearest integer and format as a string. # # See also: sprintf, num2str # modified by Ken Neighbors (wkn at sun-valley dot stanford dot edu) 21 May 1994 # It should not return "2.00000", but "2" for int2str(2.3) if (nargin == 1) if (rows (x) == 1 && columns (x) == 1) retval = sprintf ("%g", round (x)); else error ("int2str: expecting scalar argument"); endif else error ("usage: int2str (x)"); endif endfunction *************** end of int2str.m *****************