无论如何要查找 MATLAB R2014b 中 2 或 3 个月前打开的 m 文件的历史记录吗? (文件名和路径的列表)
Matlab R2014b 将其最近的文件存储在:
%APPDATA%\MathWorks\MATLAB\R2014b\MATLAB_Editor_State.xml
It's a .xml
文件,因此很容易加载和解析xmlread
。我对 xml 解析语法不太熟悉,但以下是如何获取有关文件的信息(当然要适应您的需求):
function [recentFiles] = GetRecentFiles()
%[
% Opens editor's state file
filepart = sprintf('MathWorks\\MATLAB\\R%s\\%s', version('-release'), 'MATLAB_Editor_State.xml');
filename = fullfile(getenv('APPDATA'), filepart);
document = xmlread(filename);
% Get information about 'File' nodes
recentFiles = struct([]);
fileNodes = document.getElementsByTagName('File');
for fni = 1:(fileNodes.getLength())
attributes = fileNodes.item(fni-1).getAttributes(); % Careful, zero based indexing !
for ai = 1:(attributes.getLength())
% Get node attribute
name = char(attributes.item(ai-1).getName()); % Zero based + need marshaling COM 'string' type
value = char(attributes.item(ai-1).getValue()); % Zero based + need marshaling COM 'string' type
% Save in structure
name(1) = upper(name(1)); % Just because I prefer capital letter for field names ...
recentFiles(fni).(name) = value;
end
end
%]
end
这将返回一个如下结构:
recentFiles =
1x43 struct array with fields:
AbsPath
LastWrittenTime
Name
注意:我尝试在 matlab 命令窗口中输入matlab.desktop.editor.*
,但似乎没有关于最近的文件的信息(无论如何,从命令行操作编辑器有很多有趣的事情)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)