matlab - Matlab - 调用函数文件的函数文件的路径
问题描述
我有一个调用函数(命令)的函数f0.m
(目标,任何函数,不允许修改)。f1.m
在里面f1.m
我需要知道调用者函数的路径f0.m
。
mfilename('fullpath')
并S=dbstack('-completenames'); S(1).file
给出当前文件f1.m
并matlab.desktop.editor.getActiveFilename
在编辑器中给出活动文件(无论它是什么)。
我必须为此使用什么?
解决方案
使用mfilename
or dbstack
insidef0
获取f0.m
. 将 的路径f0
作为输入参数传递给f1
.
function out_f0 = f0(inp_f0)
%whatever you have in here
f0path = mfilename('fullpath');
out_f1 = f1(inp_f1, f0path);
%...
end
function out_f1 = f1(inp_f1, f0path)
%whatever you have in here
end
推荐阅读
- javascript - 在 ember Handlebars 中使用每个
- python-3.x - 如何使用 Plotly 在 Databricks 中呈现图表?
- swift - 使用 RxSwift 处理键盘WillHide
- java - 如何为 zopfli 压缩的 png 充气
- python - Jupyter 选项卡自动完成的困难
- ansible - Ansible:覆盖角色默认值
- java - Volley jsonObjectRequest 如何处理字符串结果
- node.js - Nodejs Multer On Success 获取返回值
- python-3.x - linerrud 数据集上的线性回归
- javascript - 在移动设备上,为什么 pageYOffset + clientHeight 不等于 scrollHeight?