以八度为单位的导入功能

时间:2013-07-11 18:24:50

标签: matlab function import octave

我在octave中运行matlab代码。我想,导入功能没有在核心八度中实现。知道如何在八度音阶中使用这个matlabe函数吗?

以下是我所拥有的: 倍频3.4.0:7个建立 导入包: BRML。* 警告:“导入”功能尚未在Octave中实现

请阅读“http://www.octave.org/missing.html”以了解具体方法 缺少功能。

错误:第8行第5列附近未定义`import'

1 个答案:

答案 0 :(得分:4)

您可以自己定制import.m。来自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