Normalized data to lookup table
Show older comments
לק"י
Hello!
I got a normalized vector which I want to make as an index for lookup table (preferablt in heatmap colors or blue colors).
Thanks!
1 Comment
Answers (1)
Walter Roberson
on 11 Feb 2023
There are a number of circumstances in which you can just use the normalized values as the data, and use a colormap(), and the value will automatically be converted into a color table index. See clim (caxis in older releases)
However if you need to do the mapping manually:
NumberOfEntriesInTable = size(YourColorTable,1);
mindata = min(YourData);
maxdata = max(YourData);
proportion = (YourData - mindata)./(maxdata - mindata);
table_idx = ceil(proportion * NumberOfEntriesInTable * (1-eps));
colored_data = YourColorTable(table_idx,:);
The output, colored_data,will be a numel(YourData) by 3 array, with Red, Green, and Blue columns.
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!