
% saving matlab colormap to GMT color palette

map=colormap;
ncolors=max(size(map));

map=floor(map*255);



file=input(' Give name for *.cpt file : ');

fileout=sprintf('%s.cpt',file);
fid=fopen(fileout,'w');


for i=1:ncolors,
if i==1,fprintf(fid,' %3i %3i %3i %3i %3i %3i %3i %3i\n',i-1,map(i,1),map(i,2),map(i,3),i,map(i,1),map(i,2),map(i,3));
else 
fprintf(fid,' %3i %3i %3i %3i %3i %3i %3i %3i\n',i-1,map(i-1,1),map(i-1,2),map(i-1,3),i,map(i-1,1),map(i-1,2),map(i-1,3));end
end



