ROUND60063 rounds numeric values to the standard electronic component values defined in IEC 60063 (i.e. resistor, capacitor, and inductor values). The input may be a numeric scalar/vector/matrix/ND-array. The most appropriate rounded values are picked by calculating the rounding bin edges to approximate component tolerance boundaries. ROUND60063 returns the rounded values, the E-series values, the corresponding bin edges and indices. Supports E-series E3/E6/E12/E24/E48/E96/E192, eg E6 = [...,10,15,22,33,47,68,100,150,220,...].
### Bonus Functions ###
The bonus function ROUND60063_VIEW creates a figure that demonstrates how ROUND60063's rounding bin edges match the component tolerances. The rounding bin edges are calculated using the harmonic mean of adjacent E-series values.
The bonus function NUM2CIRCUIT uses an exhaustive search to find the component values whose equivalent circuit value is closest to the input value. The circuit can be either a parallel or series circuit (of resistors, capacitors, or inductors).
### Examples ###
>> round60063(500, 'E12')
ans = 470
>> round60063([5,42,18,100], 'E12')
ans = [4.7, 39, 18, 100]
>> round60063([5,42,18,100], 'E6') % default = 'harmonic'
ans = [4.7, 47, 22, 100]
>> round60063([5,42,18,100], 'E6', 'up')
ans = [6.8, 47, 22, 100]
>> round60063([5,42,18,100], 'E6', 'down')
ans = [4.7, 33, 15, 100]
>> round60063([5,42,18,100], 'E6', 'arithmetic')
ans = [4.7, 47, 15, 100]
>> [Y,pns,edg,idx] = round60063([5,42,18,100], 'E3')
Y = [4.7, 47, 22, 100]
pns = [4.7; 10; 22; 47; 100]
edg = [2.997; 6.395; 13.75; 29.97; 63.95; 137.5]
idx = [1, 4, 3, 5]
>> [Y,pns,edg,idx] = round60063([-Inf,Inf,NaN; -1, 0, 1], 'E3')
Y = [NaN, NaN, NaN; NaN, NaN, 1]
pns = 1
edg = [0.63946; 1.375]
idx = [NaN, NaN, NaN; NaN, NaN, 1]
Stephen Cobeldick (2021). Round to Electronic Component Values (https://www.mathworks.com/matlabcentral/fileexchange/48840-round-to-electronic-component-values), MATLAB Central File Exchange. Retrieved .
Nice add on, very handy. Thanks.
@Austin White: I added 'up' and 'down' options.
@Austin White: one way to achieve this is:
>> X = [514, 1.9; 7.6, 37; 560, 39];
>> [~,pns] = round60063(X,'E12');
where this will round down:
>> [~,idx] = histc(X,pns);
>> pns(idx) % round down
and this will round up:
>> [~,idy] = histc(-X,-pns(end:-1:1));
>> pns(1+numel(pns)-idy) % round up
It would be great if you could say to round up or down.
Inspired by: iec63.m, GUI for Resistance Calculations, Advance Resistance Calculator, Resistance Calculator, Compute the total resistance of n resistors in parallel., Number to Scientific Prefix, Resistance Calculator, Number to Words, Words to Number, Scientific Prefix to Number, resist(desired_value,p_c_error,displayall_012,ThreeResistors01)
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!