diff m-toolbox/sltpda/sltpda_fixvar.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/sltpda/sltpda_fixvar.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,25 @@
+function cmd = sltpda_fixvar(cmd)
+
+% SLTPDA_FIXVAR replaces various unwanted characters in variable names.
+% 
+% M Hewitson 11-04-07
+% 
+% $Id: sltpda_fixvar.m,v 1.2 2007/04/29 12:52:00 hewitson Exp $
+% 
+
+% some simple replacements
+cmd = strrep(cmd, ' ', '_');
+cmd = strrep(cmd, '-', '_');
+cmd = strrep(cmd, '/', '_');
+cmd = strrep(cmd, '.', '_');
+
+% check variable name doesn't begin with number - MATLAB doesn't like this
+if ~isempty(cmd)
+  n = str2num(cmd(1));
+  if ~isempty(n)
+    if isreal(n)
+      cmd = ['c' cmd];
+    end
+  end
+end
+% END