MATLAB: Loading saved colormap for use

colormap

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);

Best Answer

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