我是靠谱客的博主 搞怪煎蛋,最近开发中收集的这篇文章主要介绍matlab如何获取路径,[转载]matlab代码中获取当前m文件所在的路径 转的,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

%save m-file as aa.m

function res=aa()

clc

p1 = mfilename('fullpath')

i=findstr(p1,'')

p1=p1(1:i(end))

cd(p1)

end

a4c26d1e5885305701be709a3d33442f.png

mfilename

File name of currently running function

Syntax

mfilename

p = mfilename('fullpath')

c = mfilename('class')

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.

Tips

If mfilename is called with any argument other than the above two,

it behaves as if it were called with no argument.

When called from the command line, mfilename returns an empty

string.

To get the names of the callers of a MATLAB function file, use

dbstack with an output argument.

最后

以上就是搞怪煎蛋为你收集整理的matlab如何获取路径,[转载]matlab代码中获取当前m文件所在的路径 转的的全部内容,希望文章能够帮你解决matlab如何获取路径,[转载]matlab代码中获取当前m文件所在的路径 转的所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部