home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.disi.unige.it
/
2015-02-11.ftp.disi.unige.it.tar
/
ftp.disi.unige.it
/
pub
/
.person
/
BarlaA
/
sw
/
matlab
/
Cromwell
/
truncateName.m
< prev
next >
Wrap
Text File
|
2007-12-04
|
794b
|
22 lines
function dataname = truncateName(filename)
% dataname = truncateName(filename)
%
% This function takes as its input a string representing a file name.
% It strips off the extension (everything after the final '.') to
% create a a variable name. In order to ensure that the variable name
% is valid in MATLAB, it replaces everything that is not a normal
% letter or digit with an underscore.
% Copyright (c) 2003, 2004 UT M.D. Anderson Cancer Center. All rights reserved.
% See the accompanying file "license.txt" for details.
tmp = findstr(filename, '.');
if length(tmp) > 0,
tmp = tmp(end)-1;
dataname = char(filename(1:tmp));
else
dataname = char(filename);
end
badchar = find(~isletter(dataname) & ~ismember(dataname, '0123456789'));
dataname(badchar) = '_';