Zdata(N,1) to RGB Cdata(N,1,1:3)

1 次查看(过去 30 天)
I have lat, long, and skill vectors. All vectors are (n,1). (skill ranges from 0.0 to 1.0)
for j = 1:n_validlength;
plotm(Lat_NCOMwCodar(j),Lon_NCOMwCodar(j),0,'Marker','s','MarkerSize',12,...
'MarkerFaceColor',skill_color_NCOMatCodar(j,jj,:));
end
where skill_color_NCOMatCodar(j,jj,1:3) is colormap('jet') from skill_NCOMatCodar(j,jj)
How to set the relationship between SKILL(n,jj) range 0.0 to 1.0 to SKILL_COLOR(n,jj,1:3) ?
I can not use contourm, geoshowm, because data is not at i,j mesh, image. Ilregular grids are used.

采纳的回答

Arthur Allen
Arthur Allen 2013-3-19
Solved my own question:
cmap_jet = colormap(jet(64)); % used colormap 'jet' with 64 colors
for j = 1:n
if skill(j) == 0;
skill_color(j,:) = ([0 0 0]); % set to black
else
% return index from 1 to 64 based upon skill level (data) from 0.0 to 1.0
% note: skill.*number_of_colors_in_colormap
% note: goal: return indexes from 1 to 64 starting with data range.
skill_color_idx(j) = uint8(ceil(skill(j).*64));
% now return cmap_jet row :RGB as color of skill
skill_color(j,:) = cmap_jet(skill_color_idx(j),:); % jet colors
end
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by