m files cannot run

조회 수: 61 (최근 30일)
nebula liarny
nebula liarny 2014년 1월 23일
댓글: Walter Roberson 2014년 1월 24일
hello i have matlab 7.9 R2009b and i cannot run my m files that i create i have not completely understood in which file they must be located so that i can run them i have tried the MATLAB file that the programm created in my documents file i have also tried the matlab/bin file (i have ubuntu and matlab is installed in my home directory, unfortunately) but none of these worked :( when i try to run the m file, a window appears that is saying "file is not found in the current directory or in the matlab path. to run this file u can either change the matlab current directory or or add its directory to the matlab path" and then then u can choose either "change directory" or "add to path" but none of these work, too please, i would really appreciate it if anyone could helo
  댓글 수: 1
Image Analyst
Image Analyst 2014년 1월 23일
Are you sure. Always, that I've seen, if you have open an m-file in the editor and click the green Triangle to run it, and it says you can change directory and you do so, it will then run the file. Are you saying you just click and the button goes away and absolutely nothing at all happens?

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

답변 (3개)

Muruganandham Subramanian
Muruganandham Subramanian 2014년 1월 24일
편집: Muruganandham Subramanian 2014년 1월 24일
Use a string instead of numbers for naming *.m file (e.g. abc.m instead of 1.m). then try it
  댓글 수: 1
Walter Roberson
Walter Roberson 2014년 1월 24일
Correct. MATLAB .m file names must follow the rules for naming variables. The first character must be a (Latin) letter, and following characters can be (Latin) letters or (Latin) digits or the underscore ('_')

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


Walter Roberson
Walter Roberson 2014년 1월 23일
Make sure the filenames end in .m and there is no hidden extension. Make sure the files are readable by you. Put the files in a convenient directory that does not have MATLAB installed in it. Start up MATLAB. Use pathtool to add that directory to the MATLAB path. You should now be able to invoke the code by giving the base file name without the directory and without the extension.
If it is not able to find it, then try using "which" to see what it says. For example if the file is MyProgram.m then
which -all MyProgram

nebula liarny
nebula liarny 2014년 1월 24일
i put them in a file and added the file to the matlab path but nothing happened. my file is 1.m i wrote which -all 1 and the result was '1 not found' i wrote which -all 1.m and i got back the directories that include this file also it wrote: %shadowed
  댓글 수: 1
nebula liarny
nebula liarny 2014년 1월 24일
hmmm i thinkk the name of my m files bothered it! all my m files were named after the numbers of my exercises, etc 1,2,3 i renamed them, tried 2 of them and they are running now..

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by