index out of bounds
1 view (last 30 days)
Show older comments
Commented: dingyi duan on 30 Oct 2015
hi guys, new to matlab and came across a simple problem that takes me forever to get over. please help.
so its pretty much just mix three primary colors as input and output the mixed color.. i have a hard time going through this and i don't know where i did wrong.. thanks for answering. oh and here's the error:
Attempted to access rgb(3); index out of bounds because numel(rgb)=1.
Error in rgb_color (line 26) if rgb(3)==1
Ilham Hardy on 30 Oct 2015
Edited: Ilham Hardy on 30 Oct 2015
What is your rgb value?
The error message is very clear. it stated that you tried to access the third index of rgb, whilst rgb only contains one value ( numel(rgb)=1).
Btw, you can also use logical operator instead of nested if-else statement
More Answers (1)
Stephen23 on 30 Oct 2015
Edited: Stephen23 on 30 Oct 2015
If you want to look up colornames then use my FEX submission colornames:
It is very simple to use:
ans = 'Purple'
ans = 'Yellow'
ans = 'White'
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!