function c = profilecolors(green_val, yellow_val, red_val, v) %PROFILECOLORS Returns an interpolated RGB vector for use in CCAs. % PROFILECOLORS(green_val, yellow_val, red_val, v) returns an RGB matrix % where the position of v relative to green_val, yellow_val, and red_val % to obtain a point along the red-green color spectrum. The algorithim % uses a two sided linear interpolation about yellow_val. If v is outside % the limits of green_val or red_val, v is assigned exactly green or % yellow, as appropriate, thus bounding the range of assigned colors. % The following colors are used as boundaries for interpolation: % red = [1 0 0] % green = [0 .5 0] % yellow = [1 1 0] % Because yellow_val can be specified, both pure linear interpolation % across the entire range (set yellow_val = mean(green_val,red_val) or % asymmetric interpolation across yellow_val can be performed. % % Written by Finny Kuruvilla, v1.2.3 Last modified 9-6-2000 if (yellow_val <= min(green_val,red_val)) | (yellow_val >= max(green_val, red_val)) error('The yellow value is not between the red and green values.'); end if (v < min(green_val, red_val)) v = min(green_val, red_val); elseif (v > max(green_val, red_val)) v = max(green_val, red_val); end if (red_val > green_val) if v <= yellow_val c = [(v-green_val)/(yellow_val-green_val)... (1-(1-(v-green_val)/(yellow_val-green_val))*.5) 0]; else c = [1 (red_val-v)/(red_val-yellow_val) 0]; end else if v <= yellow_val c = [1 (v-red_val)/(yellow_val-red_val) 0]; else c = [(green_val-v)/(green_val-yellow_val)... (1-(1-(v-green_val)/(yellow_val-green_val))*.5) 0]; end end