Resistor Maker in MATLAB

Version 1.0.0.0 (2.23 KB) by Josip
A program that shows you how to arrange given resistors for a desired value!
285 Downloads
Updated 12 Nov 2013

View License

Example: Say you want a 26.5 Ohm resistor and have [1 20 2 3 1 6 3] Ohm resistors on hand...

>> rMaker(26.5,[1 20 2 3 1 6 3], 0)
The first element within tolerance
(((1||1)+6)+20) = 26.5

Where || is a parallel connection and + is a series connection.

You can even give a tolerance!

>> rMaker(16.432,[1 1 10 4 2 2 2], 0.02)
The first element within tolerance
((((((1+2)+2)||2)+1)+4)+10) = 16.4286

Not that fast, but was some fun.

This code also contains a handy function matCount that can tile every combination given to it to vector length n. You can use it to make truth tables, etc.
e.g

>> matCount([1 2], 3)

ans =

1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

>> matCount([1 0], 3)

ans =

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Cite As

Josip (2024). Resistor Maker in MATLAB (https://www.mathworks.com/matlabcentral/fileexchange/44283-resistor-maker-in-matlab), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Data Type Conversion 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
1.0.0.0