Solving Filename Issues in MATLAB 6.5.1

  • Context: MATLAB 
  • Thread starter Thread starter darkfall13
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion addresses filename issues in MATLAB 6.5.1, specifically the constraints on naming m-files. Users cannot use filenames that are not valid variable names, leading to errors when attempting to run scripts with names like "4 1 2008.m" or "FAC 4 1 2008.m". The MATLAB function isvarname is recommended to validate potential filenames. The user is advised to create a new naming scheme to avoid these issues.

PREREQUISITES
  • Understanding of MATLAB 6.5.1 syntax and file management
  • Familiarity with MATLAB m-files and their execution
  • Knowledge of variable naming conventions in MATLAB
  • Experience with MATLAB functions, specifically isvarname
NEXT STEPS
  • Research MATLAB variable naming conventions to avoid runtime errors
  • Explore the isvarname function in MATLAB for validating filenames
  • Learn about best practices for naming scripts and functions in MATLAB
  • Investigate differences between MATLAB 6.5.1 and newer versions regarding file naming
USEFUL FOR

MATLAB users, particularly those working with older versions, software developers, and data analysts who need to manage script files effectively without encountering naming issues.

darkfall13
Messages
30
Reaction score
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
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.
 
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
917
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K