Hi I am trying to run a file but i keep getting this error.

댓글 수: 6

Manikanta Aditya
Manikanta Aditya 2024년 3월 31일
편집: Manikanta Aditya 2024년 3월 31일
First save your MATLAB file name with proper name and then try to run the file as mentioned check the letters numbers and underscores.
Ibraheem
Ibraheem 2024년 3월 31일
How do I save the file with a proper name.
Thanks
Alexander
Alexander 2024년 3월 31일
It would make things easier if just show us the filename of your script.
Ibraheem
Ibraheem 2024년 3월 31일
I don't know how to create a file name.
Voss
Voss 2024년 3월 31일

In the MATLAB editor, select "Save As", as described in Steven Lord's answer:

https://www.mathworks.com/matlabcentral/answers/2100921-i-can-t-run-a-file#answer_1433926

Or you can change the m-file's name through your operating system, the same way you might rename any file.

댓글을 달려면 로그인하십시오.

 채택된 답변

Steven Lord
Steven Lord 2024년 3월 31일

1 개 추천

Most often I'd expect to see this if you tried to include either a space in the name of your MATLAB program file (not allowed) or including a set of parentheses (trying to save a file from a webpage as "myfile.m" when there is already a myfile.m in the directory and having the browser save it as "myfile(1).m" for example.)
If you have the file open in MATLAB Editor, click the downward pointing triangle below the Save icon on the Editor tab of the Toolstrip then select Save As to save it using a different name. If you want to check if the name you want to use is a valid MATLAB program file name, use the isvarname function (without the .m extension.)
validFilename1 = isvarname('myfile')
validFilename2 = isvarname('hw1_problem2')
invalidFilename1 = isvarname('my homework') % Includes a space, not allowed
invalidFilename2 = isvarname('myfile(1)') % Includes (), not allowed
invalidFilename3 = isvarname('for') % Don't name your functions with a keyword
invalidFilename4 = isvarname('1stFile') % Program files must start with a letter

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2024년 3월 31일

댓글:

2024년 4월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by