Solving Filename Issues in MATLAB 6.5.1

  • MATLAB
  • Thread starter darkfall13
  • Start date
  • Tags
    Matlab
In summary, the person is having trouble running files with certain names in their MATLAB program. They originally had an issue with a file named "any.m" and had to rename it to "anyd.m" in order for it to run. They now need to include a date in their file name, but when they do, they encounter errors or unexpected results. It turns out that MATLAB m-files need to have valid variable names, and the program interprets certain characters as operands. The person plans to use the function isvarname to check for valid variable names and come up with a new naming scheme for their files.
  • #1
darkfall13
33
0
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:
Physics news on Phys.org
  • #2
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.
 
  • #3
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 to Solving Filename Issues in MATLAB 6.5.1

What are some common filename issues in MATLAB 6.5.1?

Some common filename issues in MATLAB 6.5.1 include not being able to find or open a file, file names being too long, and file names containing special characters or spaces.

How can I solve filename issues in MATLAB 6.5.1?

To solve filename issues in MATLAB 6.5.1, you can try renaming the file to a shorter name or removing any special characters or spaces. You can also try using the full file path instead of just the file name.

Why am I getting errors when trying to access files in MATLAB 6.5.1?

The most common reason for errors when trying to access files in MATLAB 6.5.1 is due to incorrect file paths or file names. Make sure the file path is correct and that the file name does not contain any special characters or spaces.

Can I change the default file naming conventions in MATLAB 6.5.1?

Yes, you can change the default file naming conventions in MATLAB 6.5.1 by going to the Preferences menu and selecting the "File naming" option. Here, you can customize how MATLAB handles file names.

Is there a limit to how long a file name can be in MATLAB 6.5.1?

Yes, there is a limit to how long a file name can be in MATLAB 6.5.1. The maximum length for a file name is usually 255 characters, but this may vary depending on your operating system and file system limitations.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
598
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
962
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top