Cody

Problem 1683. Create different color vectors.

When producing figures with multiple lines on, you often want the lines to all be visible and different colors. Given the need for n colors, produce a cell of n different RGB color vectors, preferably as different as possible!

Examples

1) Input: x = 3; Output: y = {[1 0 0], [0 1 0], [0 0 1]}

2) Input: x = 5; Output: y = {[0 0 0], [0.5 0.5 0.5], [1 0 0], [0 1 0], [0 0 1]}

Note: to avoid colors being too close to white, it must NOT be that sum(y{i}) > 2.5

Solution Stats

72.22% Correct | 27.78% Incorrect
Last solution submitted on Feb 02, 2015
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more