⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fixname.m

📁 这个是时间序列分析的可视化工具
💻 M
字号:
function nameout=fixname(name)%FIXNAME           Make any necessary changes to NAME so that it is a valid MATLAB variable name.%  nameout=fixname(name)%% FIXNAME looks at name to see if it is a valid MATLAB variable name. If not, it%  makes any changes necessary. Leading numbers are stuck at the end.%% Ex. name='21hello.3*bg'%     nameout='hello3bg21'%%INPUT:%   name:			String which may need fixin'%                May be a cell array of strings%%OUTPUT:%   nameout:		String containing fixed name%                Empty if no valid name can be constructed from name% Scott Hirsch% 5/99%Rules for MATLAB variable names: % First char must be letter% Contains only: letters, numbers, underscoreif nargin<1   name=input('Please enter the name which needs fixin''');end;if ~isempty(str2num(name))    nameout = ['a' name];%    error('I can''t convert a number into a valid MATLAB string');   returnend;%iscll=iscell(name);letters='abcdefghijklmnopqrstuvwxyz';LETTERS=upper(letters);numbers='1234567890';validchar=[letters LETTERS numbers '_'];ind=[];for ii=1:length(name)   s=findstr(name(ii),validchar);   if ~isempty(s)      ind=[ind ii];   end;end;if isempty(ind)   nameout='';else         nameout=name(ind);   ind=1:length(nameout);      %now, take any leading numbers and put them at the end      s=-1;   ii=0;   while ~isempty(s)&isreal(s)			%isreal gets rid of i, j problem      s=str2num(nameout(ii+1));      ii=ii+1;   end;         if ii>1      nameout=[nameout(ii:end) nameout(1:ii-1)];   end;   end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -