Round to Electronic Component Values

Version 2.0.4 (63.7 KB) by Stephen23
Round numeric array values to IEC 60063 resistor/capacitor values (E-Series of preferred numbers).
1.2K Downloads
Updated 20 Jan 2024

View License

ROUND63 rounds numeric values to electronic component values defined in IEC 60063 (preferred numbers for resistor, capacitor, and inductor values, previously IEC 63). By default the rounding bin edges approximate component tolerance boundaries: an optional input selects round-to-nearest, rounding up, and rounding down.
Supports E-series E3, E6, E12, E24, E48, E96, and E192. For example, E6 = [...,10,15,22,33,47,68,100,150,220,...]
Bonus Functions
The bonus function ROUND63_VIEW creates a figure that demonstrates how ROUND63's rounding bin edges correspond to the component tolerance boundaries.
The bonus function ROUND63_TEST includes many tests of the nominal and edgecase behavior.
Examples
>> round63(500, "E12")
ans = 470
>> round63([5,42,18,100], 'E12')
ans = [4.7, 39, 18, 100]
>> round63([5,42,18,100], 'E6') % default = 'harmonic'
ans = [4.7, 47, 22, 100]
>> round63([5,42,18,100], 'E6', 'up')
ans = [6.8, 47, 22, 100]
>> round63([5,42,18,100], 'E6', 'down')
ans = [4.7, 33, 15, 100]
>> round63([5,42,18,100], 'E6', 'arithmetic')
ans = [4.7, 47, 15, 100]
>> [Y,idx,pns,edg] = round63([5,42,18,100], 'E3')
Y = [4.7, 47, 22, 100]
idx = [ 1, 4, 3, 5]
pns = [4.7; 10; 22; 47; 100]
edg = [2.9971; 6.3946; 13.75; 29.971; 63.946; 137.5]
>> [Y,idx,pns,edg] = round63([-Inf,Inf,NaN; -1, 0, 1], 'E3')
Y = [NaN, NaN, NaN; NaN, NaN, 1]
idx = [NaN, NaN, NaN; NaN, NaN, 1]
pns = 1
edg = [0.63946; 1.375]

Cite As

Stephen23 (2024). Round to Electronic Component Values (https://www.mathworks.com/matlabcentral/fileexchange/48840-round-to-electronic-component-values), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with R2009b and later releases
Platform Compatibility
Windows macOS Linux
Categories
Find more on Vector Fields in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
2.0.4

* Add edgecases to ROUND63_TEST.

2.0.3

* Improve documentation.
* ROUND63_VIEW now accepts a scalar input value.

2.0.2

* Documentation improvements.

2.0.1

* Minor edit of FEX description

2.0.0

* Simplify function name to ROUND63
* Reorder output arguments
* More robust bin edge and binning algorithm
* Accept string class or char text inputs

1.5.0.2

* Include bonus functions.

1.5.0.1

* Update documentation examples.

1.5.0.0

* Accept different input numeric types.
* Correct HTML doc example.
* Correct screenshot.

1.4.0.0

* fixed incorrect handling of fractional input values.

1.3.0.0

* Add UP, DOWN, and ARITHMETIC rounding options.
* Correct example outputs.

1.2.0.0

* Add HTML documentation.
* Change bonus function name to NUM2CIRCUIT.
* Change bonus function output array indexing.

1.1.0.0

- Edit blurb: why does the first newline always disappear?

1.0.0.0