From: <jpi...@us...> - 2012-04-15 10:50:11
|
Revision: 10223 http://octave.svn.sourceforge.net/octave/?rev=10223&view=rev Author: jpicarbajal Date: 2012-04-15 10:50:05 +0000 (Sun, 15 Apr 2012) Log Message: ----------- miscellaneous: Adding truncate function for evaluation of the community. Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/NEWS Added Paths: ----------- trunk/octave-forge/main/miscellaneous/inst/truncate.m Modified: trunk/octave-forge/main/miscellaneous/NEWS =================================================================== --- trunk/octave-forge/main/miscellaneous/NEWS 2012-04-15 09:34:12 UTC (rev 10222) +++ trunk/octave-forge/main/miscellaneous/NEWS 2012-04-15 10:50:05 UTC (rev 10223) @@ -1,6 +1,15 @@ -Summary of important user-visible changes for miscellaneous 1.1.0: -------------------------------------------------------------------- +Summary of important user-visible changes for the miscellaneous package +------------------------------------------------------------------------ +=============================================================================== +miscellaneous-1.2.0 Release Date: 2012-XX-XX Release Manager: +=============================================================================== + ** New functions: + truncate.m : truncates a number to a given precision. +=============================================================================== +miscellaneous-1.1.0 Release Date: 2012-03-24 Release Manager: +=============================================================================== + ** IMPORTANT NOTE: * the function `waitbar' has been renamed `text_waitbar'. Octave core has implemented a Matlab compatible `waitbar' which is imcompatible with the Added: trunk/octave-forge/main/miscellaneous/inst/truncate.m =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/truncate.m (rev 0) +++ trunk/octave-forge/main/miscellaneous/inst/truncate.m 2012-04-15 10:50:05 UTC (rev 10223) @@ -0,0 +1,43 @@ +%% Copyright (c) 2012 Juan Pablo Carbajal <car...@if...> +%% +%% This program 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 +%% any later version. +%% +%% This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{y} = } truncate (@var{x}, @var{order}) +%% Truncates @var{X} to @var{order} of magnitude. +%% +%% Example +%% @example +%% format long +%% x = 987654321.123456789; +%% order = [3:-1:0 -(1:3)]'; +%% y = truncate(x,order) +%% y = +%% 987654000.000000 +%% 987654300.000000 +%% 987654320.000000 +%% 987654321.000000 +%% 987654321.100000 +%% 987654321.120000 +%% 987654321.123000 +%% @end example +%% +%% @seealso{round,fix,ceil,floor} +%% @end deftypefn + +function y = truncate (x,order) + ino = 0.1.^order; + o = 10.^order; + y = round (x.*ino).*o; +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |