Hello, I am trying to get the values of the vector color to be displayed as 0 = yellow; 1 = red; 2 = green;
3 = blue; using switch-case function. I got this but it doesn't work.
color=[2,1,3,0,1,3,1,0,2]
cName ={'yellow','red','green','blue'};
for ind=1:length(color)
switch ind
case color ==0
disp(cName{'yellow'});
case color==1
disp(cName{'red'});
case color==2
disp(cName{'green'});
case color== 3
disp(cName{'blue'});
end
end
Could someone help me with this?
THANKS!
Best Answer