Answered step by step
Verified Expert Solution
Question
1 Approved Answer
When reading a resistor's color bands: The first two colored bands, pulled from Table 1, represent the first and second digits of the resistance,
When reading a resistor's color bands: The first two colored bands, pulled from Table 1, represent the first and second digits of the resistance, respectively The third colored band, pulled from Table 2, represents the multiplier applied to the first two digits. For example, if there are three zeros after the first two digits, that would be represented by an orange color as the third colored band. If there are no zeros after the first two digits, that would be represented by a black color as the third colored band. See test cases below for additional examples. Table 1: Color Codes (ColorCode) 0 Black 1 Brown 2 3 4 5 6 7 Red Orange Yellow Green Blue Violet 8 Grey 9 White Table 2: Multipliers (Multiplier) 1 10 100 1,000 Black Brown Red Orange 10,000 Yellow 100,000 1,000,000 Green Blue The goal of this program is to convert a given resistance into a set of color bands or convert a given set of color bands into a resistance value. Load in P2_ColorGuide.mat, which contains the two above variables, and accomplish the tasks as described below. Function Develop a user-defined function named Color2Resist to convert a color band to its corresponding resistance [ohms]. Assume that the color band has been formatted in the form of a vector, where every color is a different element in the vector. Determine the corresponding resistance [ohms] using Tables 1 and 2. You may assume that the colors inputted will always match the case sensitivity shown in Tables 1 and 2. Function Inputs: 1. Color band as a vector, with each color being a separate value in the vector 2. The vector, ColorCode (Table 1) 3. The vector, Multiplier (Table 2) Function Outputs: The function header should be formatted similarly to the following: function [out1] = Color2Resist (in1, in2, in3) 1. Resistance [ohms] corresponding to the inputted color band, as a vector with each digit being a separate value in the vector Remember you are free to use whatever variable names you want, but they must be listed in the same order as given in the input/output lists provided above. Command Window Converting Resistance to Color Bands Enter the resistance in ohms as a vector: [1 5 0 0 6] Error using MA4 cougarnetID (line 16) Invalid resistance entered. Program terminated. Enter the resistance in ohms as a vector: [1 0 0 0] fx The color bands for that resistance are: Brown Black Red>> |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To develop the userdefined function Color2Resist to convert a color band to its corresponding resistance ohms we need to map each color to a numerical ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started