MATLAB Runs Filename

  • MATLAB
  • Thread starter darkfall13
  • Start date
33
0

Main Question or Discussion Point

I'm having a weird problem in my copy of MATLAB at work (6.5.1.199709 Release 13 SP1). Originally I was having a problem with naming a file "any.m" as it wouldn't run. So I named it anyd.m and no problem afterward and I just assumed that word was some sort of script or something already defined in the program. Well now here's the kicker. I need to put a date in my filename now and I can't or can (really weirdly) get the files to run. Here's a few examples of filenames and what happens when they run.

4 1 2008.m
??? 4 1 2008
|
Error: Missing operator, comma, or semicolon.
FAC 4 1 2008.m
??? FAC 4 1 2008
|
Error: Missing operator, comma, or semicolon.
4-1-2008.m
ans =

-2005
(that's the really weird one)

test1m.m
File runs and displays my plot as it should



What's causing this? I have no problems naming files whatever I please on my home computer, though it is running a newer version than here at work.
 
Last edited:

Answers and Replies

166
0
Matlab m-files need to have names that are valid variable names. When you run your script, Matlab behaves as if you simply entered the name of the file into the command line. That's why the filename 4-2001-2008 gave -2005. It interpreted the dashes as minus signs. You can use the function isvarname to check to see if a string is a valid variable name.
 
33
0
OK thank you, I'll have to devise a new naming scheme for the files I need to create, and isvarname should come in handy thank you.
 

Related Threads for: MATLAB Runs Filename

Replies
5
Views
2K
Replies
3
Views
22K
Replies
4
Views
2K
Replies
5
Views
19K
Replies
3
Views
611
Replies
3
Views
12K
Replies
0
Views
1K
Replies
2
Views
2K
Top