function makemyfigure(imagefile,titletext,xtext,ytext) %MakeMyFigure illustrates how to create a nice figure %which plots your data using a function % Format: makemyfigure(imagefile,titletext,xtext,ytext) % -imagefile is a .mat file containing an image (as X) % (try with spine.mat or topo.mat) % -titletext is a string for the plot title % -xtext,ytext are strings for the x- and y- axes % Created March 28, 2001 by Bill %default values for subplot rows=3; cols=3; index=5; switch nargin case 3 ytext='y-axis'; case 2 xtext='x-axis'; ytext='y-axis'; case 1 titletext='title'; xtext='x-axis'; ytext='y-axis'; case 0 imagefile='spine.mat'; titletext='title'; xtext='x-axis'; ytext='y-axis'; end load(imagefile) if exist('X') data=X; else whos q=input('Which variable is the image?: ','s'); if ~isempty(q) & exist(q) data=eval(q); else return; end end figure subplot(rows,cols,index) imagesc(data) title(titletext) xlabel(xtext) ylabel(ytext)