ROUND60063 Examples

The function ROUND60063 rounds the input numeric values to values from the IEC 60063 "Preferred Numbers" series. Most importantly ROUND60063 simulates the tolerance range of electronic components, so that the rounding bin edges approximate the component tolerance limits.

Contents

Basic Usage

ROUND60063's first input is a numeric array of values to be rounded, the second input selects the E-series (e.g. 'E24', 'E48', 'E96', etc.):

round60063(500,'E6')
round60063(1:6,'E12')
ans =
   470
ans =
            1          2.2          3.3          3.9          4.7          5.6

Output 2: Preferred Number Series

ROUND60063's second output is a vector of contiguous values from the selected E-series, and which includes all of the values in out:

[out,pns] = round60063([1,101],'E3')
out =
     1   100
pns =
            1
          2.2
          4.7
           10
           22
           47
          100

Output 3: Bin Edges

The third output is a vector of the bin edges used to place the input values into bins (the section "Bin Edges and Component Tolerance" below explains these values in more detail):

[~,~,bin] = round60063([1,101],'E3')
bin =
      0.63946
        1.375
       2.9971
       6.3946
        13.75
       29.971
       63.946
        137.5

Output 4: Indices

The fourth output is a vector of indices idx, such that the output out = pns(idx):

[out,pns,~,idx] = round60063([1,101],'E3')
pns(idx)
out =
     1   100
pns =
            1
          2.2
          4.7
           10
           22
           47
          100
idx =
     1     7
ans =
     1
   100

Input 3: Select Rounding Method

The optional third input argument can be used to select the rounding method, and can be specified as one of 'harmonic', 'arithmetic', 'up', or 'down':

ipt = [5,42,18,100];
round60063(ipt,'E6','harmonic') % default
round60063(ipt,'E6','arithmetic')
round60063(ipt,'E6','up')
round60063(ipt,'E6','down')
ans =
          4.7           47           22          100
ans =
          4.7           47           15          100
ans =
          6.8           47           22          100
ans =
          4.7           33           15          100

Component Tolerance and Bin Edges (Harmonic Mean)

The introduction mentions that ROUND60063 simulates the component tolerance range: it does this by computing the harmonic mean of adjacent Preferred Number Series (pns) values. The harmonic mean values simulate the tolerance ranges of the component values: the means are shown as vertical green lines in the figure below. These means are the bin edges used to round the input values into the IEC 60063 values (shown as blue diamonds):

round60063_view([5,23],'E6')

Example: Parallel Resistor Values with NUM2CIRCUIT

As a form of entertainment and example for ROUND60063 I wrote the function NUM2CIRCUIT (included with the ROUND60063 zip file) that finds parallel/series electronic component values to match the input value/s. For example, to find four E12 resistors that could be used in parallel with an equivalent circuit resistance closest to 123 Ohms:

[val,eqv] = num2circuit(123, 'E12', [10,1000], 4, true)
val =
   820   560   390   390
eqv =
       122.95

Example: Numeric to Metric Prefix with NUM2SIP

An easy way to convert the numeric values to strings with metric/SI prefixes (e.g. 1000 -> '1 k') is to use my FEX submission NUM2SIP:

% One single number:
num2sip(round60063(23e5,'E6'))
% Multiple numbers:
vec = round60063([123,4567,8e9],'E24');
strcat(arrayfun(@num2sip,vec,'UniformOutput',false),'Ohm')
ans =
2.2 M
ans = 
    '120 Ohm'    '4.7 kOhm'    '8.2 GOhm'