代码之家  ›  专栏  ›  技术社区  ›  Dimitris

Matlab/Octave中所有内置符号的列表

  •  4
  • Dimitris  · 技术社区  · 6 年前

    在Mathematica中,可以获得所有内置函数的名称,例如, List 通过执行命令

    Names["List`*"]
    

    此外

    Names["context`*"] 
    

    列出指定上下文中的所有符号。E、 g。

    Names["Global`*"] 
    

    给出所有内置符号的名称(以及用户在全局上下文中定义的那些符号,如果有)。

    Matlab/Octave中是否有类似的结构?

    2 回复  |  直到 6 年前
        1
  •  5
  •   rahnema1    6 年前

    在倍频程中,可以使用以下函数:

    __operators__              : Undocumented
    __keywords__               : Undocumented
    __builtins__               : Undocumented
    __list_functions__         : Return a list of all functions (.m and .oct functions) in the load path or in the specified directory.
    localfunctions             : Return a list of all local functions, i.e., subfunctions, within the current file.
    

    和未记录的函数 __dump_symtab_info__ 这将转储包含不同作用域中的函数和变量名称的符号表:

    __dump_symtab_info__ (scope)               : Dump symbol table of the given scope
    __dump_symtab_info__ (__current_scope__)   : Dump symbol table of the current scope
    __dump_symtab_info__ ("functions")         : Dump globally visible functions from symbol table
    __dump_symtab_info__ ("scopes")            : List available scopes
    __dump_symtab_info__ ()                    : Everything
    
        2
  •  4
  •   Cris Luengo    6 年前

    据我所知,没有与八度音阶相等的音阶 __list_functions__ 在MATLAB中。但构建一个很容易:

    % Generate a list of all directories searched by MATLAB:
    pathlist = strsplit(path,pathsep);
    % Get functions and classes on search path
    functions = {};
    classes = {};
    for p = pathlist
       w = what(p{1});
       functions = [functions; ...
                    erase(w.m,'.m'); ...           % M-files
                    erase(w.mex,['.',mexext]); ... % MEX-files
                    erase(w.p,'.p')];              % and P-files are all functions
       classes = [classes; w.classes];             % here are all classes 
       % TODO: w.packages gives package directory names, examine those too!
    end
    % Remove duplicates
    functions = unique(functions);
    classes = unique(classes);
    

    上述跳过包中定义的函数(这些函数称为 package.function ,包文件以 + 字符)。正在执行 what('package') 将提供更多的函数和类名以添加到列表中。

    请注意,这并不局限于问题中的内置函数。它列出了搜索路径上的所有函数。要限制为内置函数,请仅搜索 toolbox/matlab

    我不知道如何列出操作符和关键字,但这是一个很短的列表,可以很容易地进行硬编码。MATLAB有一个函数 iskeyword 这将告诉您给定的名称是否为关键字。此函数的源( type iskeyword edit iskeyword )包含此列表。

    Here are all operators


    相关,功能 inmem 列出当前加载的所有函数。这些是自MATLAB启动或上次调用以来实际使用的函数 clear functions clear all .请注意,函数可以将自身锁定在内存中,而不能用 清除功能