Matlab file MAC - Script Error
Show older comments
For my work I have to upload a MATLAB script to this website. The script originally runs fine. When I then download the file once submitted and then run the script, the script won't work. It says the error is that the filename must only contain letters, numbers or underscores and that the file name isn't valid.
(I am using a MAC). Can anyone help me solve the issue ? It seems like when I upload the file to the website, it changes the file name by adding a (number) at the end of the original file name.
Answers (1)
Steven Lord
on 7 Feb 2023
1 vote
Did you already have a copy of the file in the directory to which you downloaded? I'm not sure if Mac behaves the same way as Windows does, but I'd guess it probably does. Windows will append " (2)", " (3)", etc. to the file name if you try to download the same file multiple times. Neither spaces nor parentheses are allowed in the names of MATLAB program files.
So if you're trying to run myfunction.m that would work. If you then downloaded myfunction.m again (so its name is now "myfunction (1).m") you'll need to rename it.
4 Comments
ihsvoaopk
on 7 Feb 2023
Yes - it exactly did this ' append " (2)", " (3)", etc. to the file name '. I already had a copy of the file in the directory to which I downloaded.
I did what you said - the file now says "worksheet.m". When I download it it says "worksheet (1).m". I then rename it and it is fine.
Question: I have to submit this as an assignment for homework. Am I right in assuming that when my teacher downloads the file, the script should run smoothly straight away without having to rename the file or anything ?
Walter Roberson
on 7 Feb 2023
You can assume that the file name you upload into will be the name that is used by the grading software.
ihsvoaopk
on 7 Feb 2023
So, when my teacher downloads the file, the script should run smoothly straight away without having to rename the file or anything, since it will be their first time downloading the file ?
Walter Roberson
on 7 Feb 2023
As long as the file name is a valid MATLAB identifier.
Categories
Find more on Downloads in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!