How can I calculate the resistance of a color coded resistor based on its band color?

2 次查看(过去 30 天)
I am working on a project to calculate the resistance & I need the code required for this task.

回答(1 个)

Bshara Murr
Bshara Murr 2017-11-20
First each color is assigned to a number, you can search the internet for those. Now once you have those you start replacing the first two numbers by their values, say the first two colors are yellow(4) and red(2), you write 42 the third color would be the power of 10 multiplied by the number you got. Say brown(1) is the third color you will have now 42.10^1=420 ohms. The last color will be the tolerance.
As to the code you will have to write it yourself, i have already done most of the job for you but here's a hint, you ask the user to enter the first color and you get it with switch case, and replace each color by the corresponding number, or if you are not familiar with this method you can simply use "if" and "elseif" for each entered color. Good luck

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by