MATLAB: Converting a numeric array into a string array with their corresponding values

if statement

I am trying to convert a user inputted resistance value to its appropriate color band.
The user is told to input a value for resistance in the form of a vector.
If, for example, the user inputs [1 0 0 0], How do I output [Brown, Black, Red] as the appropriate color band sequence using conditional statements?
When converting resistance to a color band, the following should be considered:
BLACK(0) BROWN(1) RED(2) ORANGE(3) YELLOW(4) GREEN(5) BLUE(6) VIOLET(7) GREY(8) WHITE(9)
The first and second colors in the color band are determined by their associated number.
The third, final, color in the color band is determined by the following:
black(1) brown(10) red(100) orange(1000) yellow(10000) green(100000) blue (1000000)
For example, if the user enters [2 7 0 0 0]
2 corresponds with red, 7 corresponds with violet and there are three zeros so the last color is orange
[red violet orange]
With those rules in mind, how do I complete this task?

Best Answer

cl = {'BLACK' 'BROWN' 'RED' 'ORANGE' 'YELLOW' 'GREEN' 'BLUE' 'VIOLET' 'GREY' 'WHITE'};
%input = [2 7 0 0 0];
input=[1 0 0 0]
s = cl([input(1:2)+1, length(input)-1])
Related Question