Code covered by the BSD License  

Highlights from
Order of magnitude of number


5.0 | 5 ratings Rate this file 23 Downloads (last 30 days) File Size: 1.24 KB File ID: #28559

Order of magnitude of number



26 Aug 2010 (Updated )

Returns the order of magnitude of one or more numbers.

| Watch this File

File Information

Returns the order of magnitude of one or more numbers. Works on arrays. You can also specify the number base.

order( 1.2e-5 ) %returns -5
order(1) = 0
order( 1.12344e8 ) %returns 8
%Specify base 2:
order(1.2*2^5,2) %returns 5


Logb inspired this file.

This file inspired Seround: Round Value And Standard Error.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
17 Jul 2012 Carlos


09 Jun 2012 Ndilokelwa Luis


04 Apr 2012 John

I see what you're doing and it makes sense, thanks for the reply!

04 Apr 2012 Ivar Eskerud Smith

Thanks John. But I think one should leave the order of magnitude of 0 to be minus infinity, that`s just what it is. If you set it to zero, consider this:
o = order(x);
x2 and x should then be the same, but they won`t be if you set the order to 0. x2 would then be 1.

03 Apr 2012 John

added the following to the bottom:

% If the value is zero then the order is set to zero
n(isinf(n)) = 0;

03 Apr 2012 John

works great!

18 Jun 2012

Added possibility to specify base.

Contact us