I should mention that I don't have the same issue using colormap(jet(Range)), but my data is subtle enough to need the extra colors that hsv provides.
Problem with colormap command using hsv
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi There. I'm still a relatively elementary-level Matlab programmer, and I've come across a problem with a figure I'm making for my thesis. The plot is fairly complex, but the problem really shouldn't be. I have a range of data, and I tailor the colors of plot to the range that I compute (which can change each time I run my code). At the moment the range is 94 units, so I first tell my plot the color axis: caxis([MinValue MaxValue]), and then define the colormap as colormap(hsv(Range)) where Range is (MaxValue-MinValue)+1. In my experience this shouldn't be a problem, but the colormap command, which is essentially the same here as saying "make me an hsv matrix that is 94 entries down and three across" keeps spitting back this error:
Error using ==> set All colormap intensities must be between 0 and 1
Error in ==> colormap at 95 set(figH, 'Colormap', arg);
The worst part is that this error usually happens, but in some small number of cases, it doesn't, and the plot comes up just fine. I can't find any reason for this inconsistency.
I do plot a lot of other figures in my code, and I'm wondering if somehow I'm overloading the colormap command, but every time I've gone into colormap and set a setpoint at line 95, I've checked the arg and arg1 matrices it uses and none have values that are below 0 or above 1. It's a mystery to me, and I'm inclined to think it's a bug in hsv unless I'm really screwing up the use of the colormap command in the first place. I will say I've successfully used this command almost exactly as this one appears many times in the past without problem...
Any help you can give is greatly appreciated.
Best, Jonathan
Réponse acceptée
Walter Roberson
le 16 Août 2013
At the command line give the command
format long g
cmap = hsv(Range);
size(cmap)
min(cmap(:))
max(cmap(:)) - 1
Do this checking just in case the values are near but not exactly what you need.
5 commentaires
Image Analyst
le 19 Août 2013
Modifié(e) : Image Analyst
le 19 Août 2013
What did Walter's code spit out for max and min in the situations where it bombed? I find it hard to believe that in the case where it bombed it said a min of 0 and a max of 1 (or anything inside that range). If it did, then it wouldn't/shouldn't have bombed.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Orange dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!