Jet/RGB Colormap with negative indices

2 ビュー (過去 30 日間)
Ignacio Lobato
Ignacio Lobato 2015 年 4 月 16 日
コメント済み: Ignacio Lobato 2015 年 4 月 16 日
Hi! I would like to be able to use the colorbar for negative indices, my code is the following:
number_of_colors=100;
%Intensities %matrix with 80 values between -0.1 and 0.1
%Maximum %maximum value for the colormap
%Minimum %minimum value for the colormap
%code
cmap = jet(number_of_colors);
values = transpose(handles.Intensities(:,2)); % the intensities
% Calculate the respective index in the colormap for every value
idx_in_colorbar = floor(1+ (values - Minimum) / (Maximum -Minimum) * (number_of_colors-1));
colormatrixfunctionoutput = cmap(idx_in_colorbar,:);
The problem is that the user of the GUI defines himself the maximum and minimum value and when they are too low, idx_in_colorbar has negative values and it cannot be passed to the next line as the indices have to be positive (ERROR: Subscript indices must either be real positive integers or logicals.) Thank you for your help!
  1 件のコメント
Ignacio Lobato
Ignacio Lobato 2015 年 4 月 16 日
I could solve it with the following:
% Convert value of index to RGB matrix
RGB=ind2rgb(idx_in_colorbar, colm);

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by