Loading saved colormap for use

63 次查看(过去 30 天)
How do i save and open a colormap for use
I have a custom colormap saved as a .mat file in the same folder as my script, but I'm unable to get the script to call upon the colormap file for use
I'd like to be able to open the script on a different computer, and have the colormap load in for use, without having to set a custom colormap each time.
I've tried combinations of the code below, to no avail
load ('topocmap.mat')
colormap= ('topocmap.mat');
cmap=colormap(gca);

采纳的回答

Walter Roberson
Walter Roberson 2021-2-16
You assigned a value to a variable named colormap but then you expect to be able to call colormap() as a function.
colormap() does not accept the name of a '.mat' file. If you pass colormap a name, it has to be the name of a function (not a .mat file.)
load() the saved data from the .mat file, and colormap() it into effect. For example,
tdata = load('topocmap.mat'); %load into structure
colormap(tdata.topocmap) %activates it
assuming that the name of the variable stored in the file is topocmap
  3 个评论
Autumn P
Autumn P 2021-12-2
I am new to matlab and I am wondering how I can then use the loaded in color map when generating a figure?
Walter Roberson
Walter Roberson 2021-12-2
Yes, if you were to make a colormap() call like that, it would affect the current "traditional" figure. If you are using App Designer then you should add a figure or axes handle to the colormap() call so it gets applied against the uifigure instead of opening a new traditional figure. (It is a good idea to pass in the parent figure or axes handle even for traditional figures.)

请先登录,再进行评论。

更多回答(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