在MATLAB中查找当前m文件的位置 [英] Find location of current m-file in MATLAB

查看:888
本文介绍了在MATLAB中查找当前m文件的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在许多地方使用 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.)

推荐答案

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆