About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconPreferred Number Rounding (Scripts) Publisher's description

Round the elements of a numeric input vector to the nearest "preferred number" values.

Round the elements of a numeric input vector to the nearest "preferred number" values.

Why This Function?

Many parts and components in engineering and electronics are defined by "preferred value" or "preferred number" series. For example this includes the values of resistors, capacitors, inductors, screw sizes, metal thicknesses, motor ratings, cog teeth-count, etc. The results of your MATLAB calculations can use this function to automatically select the closest matching preferred values...

Or maybe you want to create a histogram with non-equally spaced edges (unlike MATLAB's evenly spaced "hist")...

Or maybe you need to round some numbers to arbitrary divisions, or want numbers that all start with the same digit/s...

This function rounds the elements of a horizontal numeric vector to values chosen from a preferred number series. The input values must be real, positive and finite.

The preferred number series may be one of:
# Standard series (1-2-5, Renard and electronic IEC 60063 are inbuilt).
# Custom series (repeating every decade, supplied as a numeric vector).
# Custom function (function in one variable).

### Examples ###

prefnum([514,7.6,37,0.9],'E6') % Electronic E6
ans = [470,6.8,33,1]

prefnum([514,7.6,37,0.9],'E12') % Electronic E12
ans = [560,8.2,39,0.82]

prefnum([514,7.6,37,0.9],'R10') % Renard R10.
ans = [500,8.0,40,1]

prefnum([514,7.6,37,0.9],'R"5') % Renard R"5
ans = [600,6.0,40,1]

prefnum([514,7.6,37,0.9],'125') % 1-2-5
ans = [500,10,50,1]

prefnum([514,7.6,37,0.9],[25,75]) % Custom vector (two steps per decade)
ans = [750,7.5,25,0.75]

prefnum([514,7.6,37,0.9],1) % Custom vector (one step per decade, nearest order of magnitude)
ans = [100,10,10,1]

prefnum([514,7.6,37,0.9],@(x)2^x) % Custom function (nearest binary / power of two)
ans = [512,8,32,1]

[A,B] = prefnum([5,300],'E12') % electronic E12 nearest to the integers 5 to 300
A = [4.7,330]
B = [4.7,5.6,6.8,8.2,10,12,15,18,22,27,33,39,47,56,68,82,100,120,150,180,220,270,330]

[~,~,E,H] = prefnum(1:149,'125',0) % Draw histogram of integers 1 to 149, with unequally spaced edges.
L = arrayfun(@num2str,E,'UniformOutput',false)

### Inbuilt Preferred Number Series ###

# 1-2-5 Series

# Electronic (IEC 60063) (resistors, capacitors, inductors, zener diodes...):

E6, E12, E24, E48, E96, E192

# Renard:

R5, R10, R20, R40, R80, R'5, R'10, R'20, R'40, R"5, R"10, R"20

System Requirements:

No special requirements.
Program Release Status: Minor Update
Program Install Support: Install and Uninstall

Preferred Number Rounding (Scripts) Tags:

Click on a tag to find related softwares

Is Preferred Number Rounding (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.