先前在MATLAB中打开的m文件的历史

use*_*243 5 matlab history

无论如何,从2个月或3个月前在MATLAB R2014b中找到以前打开的m文件的历史记录?(文件和路径名称列表)

Cit*_*ane 10

Matlab R2014b将其最近的文件存储在:

%APPDATA%\MathWorks\MATLAB\R2014b\MATLAB_Editor_State.xml
Run Code Online (Sandbox Code Playgroud)

它是一个.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
Run Code Online (Sandbox Code Playgroud)

这将返回如下结构:

recentFiles = 

1x43 struct array with fields:

    AbsPath
    LastWrittenTime
    Name
Run Code Online (Sandbox Code Playgroud)

注意:我尝试输入matlab命令窗口matlab.desktop.editor.*,但似乎没有关于最近文件的内容(无论如何,从命令行操作编辑器有很多有趣的事情)