导出 MATLAB 方法视图的输出
Exporting the output of MATLAB's methodsview
MATLAB 的 methodsview
工具在探索外部 类(Java、COM 等)提供的 API 时非常方便。下面是此函数如何工作的示例:
myApp = actxserver('Excel.Application');
methodsview(myApp)
我想保留此 window 中的信息以供将来参考,方法是将其导出到 table、cell
字符串数组、.csv
或另一种类似的格式,最好不使用外部工具。
我试过的一些东西:
此 window 允许一次选择一行并执行 "Ctrl+c Ctrl+v",这会产生一个制表符分隔的文本,如下所示:
Variant GetCustomListContents (handle, int32)
当只有几种方法时,这种策略可以奏效,但对于(通常遇到的)长列表不可行。
我找不到通过图形句柄访问 table 数据的方法(w/o 使用 findjobj
or uiinspect
等外部工具),因为 findall(0,'Type','Figure')
根本“看不到” methodsview
window/figure。
我的 MATLAB 版本是 R2015a。
幸运的是,methodsview.m
文件是可访问的,可以让我们深入了解函数的工作原理。里面是下面的评论:
%// Internal use only: option is optional and if present and equal to
%// 'noUI' this function returns methods information without displaying
%// the table. `
经过反复试验,我看到了以下效果:
[titles,data] = methodsview(myApp,'noui');
... 和 returns 两个 java.lang.String[][]
.
类型的数组
从那里我找到了几种以有意义的方式呈现数据的方法:
Table:
dataTable = cell2table(cell(data));
dataTable.Properties.VariableNames = matlab.lang.makeValidName(cell(titles));
元胞数组:
dataCell = [cell(titles).'; cell(data)];
重要说明:在 table 情况下,“Return Type
”列标题重命名为 ReturnType
,因为 table 标题必须是有效的 MATLAB 标识符, as mentioned in the docs.
MATLAB 的 methodsview
工具在探索外部 类(Java、COM 等)提供的 API 时非常方便。下面是此函数如何工作的示例:
myApp = actxserver('Excel.Application');
methodsview(myApp)
我想保留此 window 中的信息以供将来参考,方法是将其导出到 table、cell
字符串数组、.csv
或另一种类似的格式,最好不使用外部工具。
我试过的一些东西:
此 window 允许一次选择一行并执行 "Ctrl+c Ctrl+v",这会产生一个制表符分隔的文本,如下所示:
Variant GetCustomListContents (handle, int32)
当只有几种方法时,这种策略可以奏效,但对于(通常遇到的)长列表不可行。
我找不到通过图形句柄访问 table 数据的方法(w/o 使用
findjobj
oruiinspect
等外部工具),因为findall(0,'Type','Figure')
根本“看不到”methodsview
window/figure。
我的 MATLAB 版本是 R2015a。
幸运的是,methodsview.m
文件是可访问的,可以让我们深入了解函数的工作原理。里面是下面的评论:
%// Internal use only: option is optional and if present and equal to %// 'noUI' this function returns methods information without displaying %// the table. `
经过反复试验,我看到了以下效果:
[titles,data] = methodsview(myApp,'noui');
... 和 returns 两个 java.lang.String[][]
.
从那里我找到了几种以有意义的方式呈现数据的方法:
Table:
dataTable = cell2table(cell(data)); dataTable.Properties.VariableNames = matlab.lang.makeValidName(cell(titles));
元胞数组:
dataCell = [cell(titles).'; cell(data)];
重要说明:在 table 情况下,“Return Type
”列标题重命名为 ReturnType
,因为 table 标题必须是有效的 MATLAB 标识符, as mentioned in the docs.