Set Matlab figure to a particular size:
 set(gcf, 'PaperSize', [8 8]);
 set(gcf,'Units','centimeters')
 set(gcf,'Position',[2,2,8,8])  
Use invisible figure and plot to file:
f2= figure('visible','off');
pav=sprintf('%f.png',x)
saveas(f2,pav,'png')
close(f2)  
Make automatic legend:
 legendCell = strcat('N=',string(num2cell(1:nN)));
 legend(legendCell); 
or
 for iN = 1:nN
    legendCell{iN} = num2str(N(iN),'N=%-d');
 end
legend(legendCell); 
Plot matrix without interpolations
 x = [5 8];
 y = [3 6];
 C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
 imagesc(x,y,C)
 set(gca,'YDir','normal') 
Function to find all objects in figure with particular property:
 plot(rand(50,1),'r.'), hold on
 plot(rand(50,1),'gs')
 plot(rand(40,1),'r*')

 a=findall(gcf,'color','r')  
Function for the custom color map:
makeColorMap.m The original can be found here.
Function for the estimation of two curve intersections:
intersections.m The original can be found here.