Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab: Saving and Running M-files

  1. Jul 21, 2007 #1
    I've noticed a weird thing that Matlab does whenever I save my m-file then try to run it. If I save my M-file with a simple file name like "HW4" or "untitlited" it will run. However if i save my m-file as file name HW#4_3.40 (I just wanted to label the file with the problem # from the text I'm using), the option for run is not highlighted and it doesn't work if I do command run HW#4_3.40. I also made sure that the target directory is correct. When I check the folder I saved the m-file file name HW#4_3.40 is detected by windows as an unknown file, while other files with simple names is detected as m-file.

    I searched a little to maybe find out if this is a bug or something. I'm somewhat new to matlab so I'm not sure if there are some restrictions to filenames for m-files. Also I am using Matlab R2006a.
     
  2. jcsd
  3. Jul 21, 2007 #2

    cristo

    User Avatar
    Staff Emeritus
    Science Advisor

  4. Jul 21, 2007 #3
    Thanks for the link. I tried taking out the #, but it didn't work. I played around with isvarname to test the file names. Guess it doesn't like periods or even hyphens. I did find a way around this by going to the folder the file is saved in and adding a ".m" to the end of the filename, but that's somewhat annoying to keep doing.
     
  5. Jul 21, 2007 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    When you enter the file's name to be saved, the dialog box will automatically append .m, but only if there are no other periods already in the file name.

    - Warren
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Matlab: Saving and Running M-files
  1. MATLAB and M-Files (Replies: 4)

  2. Matlab file saving. (Replies: 3)

  3. MATLAB - geometry M-file (Replies: 20)

Loading...