Case sensitive feature fails

4 Ansichten (letzte 30 Tage)
fuchang wang
fuchang wang am 29 Jul. 2019
Kommentiert: fuchang wang am 30 Jul. 2019
version: MATLAB R2018a
surf(peaks)
>> colormap BlueDarkOrange18
Error using feval
Cannot find an exact (case-sensitive) match for 'bluedarkorange18'
The closest match is: BlueDarkOrange18 in /usr/local/MATLAB/R2018a/toolbox/matlab/ncl_rgb/BlueDarkOrange18.m
Error in colormap (line 91)
arg = feval(arg);
My question is that, what I typed is 'BlueDarkOrange18', the error hints translated it into 'bluedarkorange18', this operation doesn't make sense.
  6 Kommentare
Steven Lord
Steven Lord am 29 Jul. 2019
There is another alternative than changing the case of the function that defines your new colormap, and that is to change how you call colormap. The colormap function can accept the name of a colormap or an M-by-3 matrix that defines the colormap. Instead of calling colormap like this:
colormap BlueDarkOrange18
call it like this:
colormap(BlueDarkOrange18)
To support this, the BlueDarkOrange function should handle being called with either 0 or 1 inputs. With 0 inputs, it should return a matrix with a number of rows equal to the number of rows in the current figure's Colormap or the number of rows in the default colormap if there is no figure open. See the block of code at the start of the parula function for an example of how to obtain this information. With 1 input, if that input is a nonnegative scalar integer value it should return a colormap with that many rows.
fuchang wang
fuchang wang am 30 Jul. 2019
For some diagnosis packages that use multiple sofwares like matlab and NCL,
they set the enviromental variable in main shell script :
export COLORMAP=BlueDarkOrange
and get this variable in both matlab scripts and NCL scripts like:
color = getenv('COLORMAP')
thus the consistency of colormap names is important here. that's the reason I prefer to keep BlueDarkOrange.
Joel Handy's myColormap.m is a perfect solution, in this way people who use my package don't have to change their own colormap.m. appreciate it. Also thanks to other comments, reminding me that it's not good to change matlab's own codes.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by