八度导入功能 [英] import function in octave
问题描述
我正在以八度运行Matlab代码.我想导入功能不是在核心八度音程中实现的.知道如何在八度中使用此matlabe函数吗?
I am running matlab code in octave. The import function is not implemented in core octave, I guess. Any idea how to use this matlabe function in octave?
这是我所拥有的: octave-3.4.0:7>设置 导入包: brml.* 警告:导入"功能尚未在Octave中实现
Here is what I have: octave-3.4.0:7> setup Importing packages: brml.* warning: the `import' function is not yet implemented in Octave
请阅读" http://www.octave.org/missing.html "以学习如何 贡献缺少的功能.
Please read `http://www.octave.org/missing.html' to learn how you can contribute missing functionality.
错误:第8行第5列附近的导入"未定义
error: `import' undefined near line 8 column 5
推荐答案
您可以创建自己的自定义import.m.来自 http://octave.1599824.n4.nabble.com/namespace- support-td1638758.html :
You can make your own custom import.m. From http://octave.1599824.n4.nabble.com/namespace-support-td1638758.html:
function import(varargin)
error(nargchk(1, inf, nargin, "struct"));
for i=1:nargin
[names, funcs] = import1(varargin{i});
for j=1:length(names)
assignin("caller", names{j}, funcs{j});
endfor
endfor
endfunction
function [names, funcs] = import1(pkgname)
pkgname_parts = strsplit(pkgname, ".");
if length(pkgname_parts) > 2
error("invalid package name: %s", pkgname);
endif
pkgpath = locatepkg(pkgname_parts{1});
unwind_protect
cwd = pwd;
cd(pkgpath);
names = what(pwd);
names = {names.m{:}, names.mex{:}, names.oct{:}};
names = cellfun(@stripExtension, names, "UniformOutput", false);
if length(pkgname_parts) == 2
if any(strcmp(pkgname_parts{2}, names))
names = {pkgname_parts{2}};
else
error("function `%s' not found in package `%s'", ...
pkgname_parts{2}, pkgname_parts{1});
endif
endif
funcs = cellfun(@str2func, names, "UniformOutput", false);
unwind_protect_cleanup
cd(cwd);
end_unwind_protect
endfunction
function pkgpath = locatepkg(pkgname)
pathdirs = strsplit(path, pathsep);
for iPath=1:length(pathdirs)
pkgpath = [pathdirs{iPath} filesep "+" pkgname];
if exist(pkgpath, "dir")
return;
endif
endfor
error("package `%s' cannot be located in the path", pkgname);
endfunction
function fileName = stripExtension(fileName)
dotIndices = strfind(fileName, ".");
fileName = fileName(1:(dotIndices(end)-1));
endfunction
这篇关于八度导入功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!