Q:

A script rancolors displays random colors in the Figure Window as shown in the Figure below. It starts with a variable nColors which is the number of random colors to display (e.g., below this is 10)

0

A script rancolors displays random colors in the Figure Window as shown in the Figure below. It starts with a variable nColors which is the number of random colors to display (e.g., below this is 10). It then creates a colormap variable mycolormap, which has that many random colors, meaning that all three of the color components (red, green, and blue) are random real numbers in the range from 0 to 1. The script then displays these colors in an image in the Figure Window

Figure Rainbow of random colors 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

rancolors.m

% Create n random colors and then display

% these in a row vector "image"

ncolors = 10;

mycolormap = rand(ncolors,3);

colormap(mycolormap)

vec = 1:ncolors;

image(vec)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now