Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: Is there a way to get the path of the current script? [duplicate]

Tags:

matlab

Possible Duplicate:
Find location of current m-file in Matlab

I have a script that is not in the current directory or on the search path. I want to get the location of the script from the script. Is this possible in Matlab?

like image 827
Rich C Avatar asked May 22 '11 21:05

Rich C


People also ask

How do I get the current path in MATLAB?

To open the Current Folder browser if it is not currently visible, do one of the following: MATLAB Toolstrip: On the Home tab, in the Environment section, click Layout. Then, in the Show section, select Current Folder. MATLAB command prompt: Enter filebrowser .

How do I get the script file in MATLAB?

Highlight commands from the Command History, right-click, and select Create Script. On the Home tab, click the New Script button. Use the edit function. For example, edit new_file_name creates (if the file does not exist) and opens the file new_file_name .

Can you run two MATLAB scripts at the same time?

Direct link to this comment I found out today that I can open MATLAB two times and then run the two scripts using each MATLAB - it works!


1 Answers

mfilename

Description

mfilename returns a string containing the file name of the most recently invoked function. When called from within the file, it returns the name of that file. This allows a function to determine its name, even if the file name has been changed.

p = mfilename('fullpath') returns the full path and name of the file in which the call occurs, not including the filename extension.

c = mfilename('class') in a method, returns the class of the method, not including the leading @ sign. If called from a nonmethod, it yields the empty string.

like image 72
Jacob Avatar answered Oct 01 '22 15:10

Jacob