问题描述
我正在许多不同的位置处理我的 MATLAB 代码,它会如果我能让代码知道它在计算机上的位置,那真的很有帮助.我认为有一个函数可以准确地为我提供这些信息,但我不记得它叫什么,也无法在 Google 上找到.
I'm working on my MATLAB code in a number of different locations, and it would really help if I could make the code aware of its location on the computer. I think there is a function that gives me exactly this information, but I can't remember what it is called or find it on Google.
这个想法是我有一个函数 myFunc
需要一个文件在它自己的目录中,它可以在不同的计算机上的不同位置.所以在 myFunc
我想做这样的事情:
The idea is that I have a function myFunc
that needs a file in its own directory, which can be in different locations on different computers. So in myFunc
I want to do something like this:
dir = theFunctionImLookingFor;
system(fullfile(dir, 'someApp.exe'));
(也可能是我要查找的函数不返回目录,而是返回目录 + m 文件名,但这对我来说没什么区别.)
(It could also be that the function I'm looking for doesn't return the directory, but the directory + m-file name, but that makes little difference to me.)
推荐答案
mfilename 或更好的 mfilename('fullpath')
这篇关于在 MATLAB 中查找当前 m 文件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!