function M=read(name)
% M=read(name): read and return ascii matrix file
% name may be with or without .txt extension

if name(end-3)~='.'
	name=[name '.txt'];
end

load('-ascii',name);
last=max(findstr(name,'\'));
if ~isempty(last)
	name=name(last+1:length(name));
end
last=max(findstr(name,'/'));
if ~isempty(last)
	name=name(last+1:length(name));
end
if name(1)=='.'
	name=name(2:length(name));
end
if name(1)>='0' & name(1)<='9'
	name=['X' name];
end

dot=max(findstr(name,'.'));
if ~isempty(dot)
	name=name(1:dot-1);
end
rr=findstr(name,'.'); name(rr)=repmat('_',1,length(rr));
rr=findstr(name,'&'); name(rr)=repmat('_',1,length(rr));
eval(['M=' name ';']);

