Matlab:有没有办法获取当前脚本的路径? [英] Matlab: Is there a way to get the path of the current script?

查看:1422
本文介绍了Matlab:有没有办法获取当前脚本的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在Matlab中查找当前m文件的位置

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

我有一个不在当前目录或搜索路径中的脚本.我想从脚本中获取脚本的位置.在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?

推荐答案

说明

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')返回 文件的完整路径和名称 发生通话的地方,不包括 文件扩展名.

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'), 返回方法的类,而不是 包括前导@符号.如果 从非方法调用,它会产生 空字符串.

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.

这篇关于Matlab:有没有办法获取当前脚本的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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