matlab - Colormatrix from colorvector -
I have a scatter 3 plot in which I use vector C to define the colors of different points. Here the color of the colormap is linearly in C, which is mapped to numbers. Somehow I want to find RGB values of each value inside my C vector. So I want 3 matrix by X out of my C vector. Anyone knows that this is possible?
Good luck, Akim
EDIT: Thanks to @Abaz, I was able to solve this problem. Here's my solution:
colors_current = colormap; Color = [color zero (length (color), 2)]; Stepw = Floor (Length) / Length (color field); Colorsort = sortrows (color); Color_old = 0; Counter = 1; I = stepw for: stepw: length (jas) color_indices = find (color_old & lt; color (,, 1) & color (:, 1) & lt; color_sort (i)); If the counter & gt; = Break the length (color scope); J = 1 for the end length (color_directory) JAbs (color_indices (j), :) = colors_current (counter, :); End color_old = colorost (i); Counter = counter + 1; P> The function used with any argument, by changing the RGB code for each color by each matrix, changes the current axes to form a meter in appearance. From there you can get RGB code for every element in your vector. Update: Forgive me, I have to forget your question because I did not know that you were looking for a clear way to get RGB code, just colormap and RGB The relationship between the code. Anyway I think you have got the solution, done well. Make a quick try yourself which I give you here: n = 10; C = RAND (N, 1); Map = color map (jet); Cregspaced = (min (c): (max) C (min) C (minus) / (size (map, 1) -1): maximum (C)); Cmapindex = interp1 (Cregspaced, (1: size (map, 1)), c, 'closest'); Crgb = Map (Cmapindex, :); This should work, depending on how matlab repeats the index for the color command. You can see it against your own solution to see what results are available.
Comments
Post a Comment