Borrar filtros
Borrar filtros

Color maps and for loops

1 visualización (últimos 30 días)
sweetdreams
sweetdreams el 4 de Mayo de 2015
Respondida: Nobel Mondal el 4 de Mayo de 2015
The color map, map , is to have the RGB values for four colors. I want to establish map as an array of zeros with a row for each color and three columns for the amounts of red, green, and blue. This is what I've got:
map = zeros(4,3)
Is that right?
Then using a for loop, I want to assign to each row of map the RGB values for a shade of red with red values from 1/4 to 4/4 = 1. I.E. each row should have a red value of i/4 and blue and green values of zero.
for i=1:map
map(4,end + rand(0.25,1));
end
^ That's what I've done and it obviously isn't right but I don't know how to fix it.

Respuesta aceptada

Nobel Mondal
Nobel Mondal el 4 de Mayo de 2015
I guess, this is what you're looking for:
myMap = zeros(4,3);
for i=1:4
myMap(i,1) = i/4;
end
firstColorMap = myMap(1,:);
secondColorMap = myMap(2,:); %etc

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by