%function mysaveas(imFile)
function mysaveas(imFile)

figure(gcf)
str = get(get(gca,'Title'),'String');
if isempty(str), str = 'untitled'; end
str = [str '.jpg'];
if ~nargin | isempty(imFile),
	imFile = [];
	[fname,pname] = uiputfile(str,'Save image as:');
	if fname == 0, return, end
	imFile = [pname fname];
else
	fname = fliplr(strtok(fliplr(imFile),'\/'));
end

try,
	saveas(gcf,imFile,'jpg')
	msgbox(['Saved figure to ' imFile])
catch, errorbox, end