Recover a longer list of recent files from the Matlab editor

六眼飞鱼酱① 提交于 2019-12-22 13:58:31

问题


I have lost the location of a .m file I recently wrote with the Matlab editor. I don't remember how I named it so the usual finder search is not helping.

The Matlab editor lets me open 'recent files' but only the few newest. Is there a way to recover a longer list of recently opened files?


回答1:


That information seems to be stored in the Matlab preference folder. That folder is given by the function prefdir. Specifically, the file 'matlab.prf' seems to contain the list of recent files. To open that file and inspect it manually you can use

open(fullfile(prefdir, 'matlab.prf'))

Recent file information seems to be contained in lines beginning with EditorMRU. I have observed that in R2010b and R2014b. Other Matlab versions may behave differently.

You could also programmatically read that file with importdata,

x = importdata(fullfile(prefdir, 'matlab.prf')); %// R2010b or R2014b
x = x.textdata; %// include this line if using R2014b; not if using 2010b

This gives x as a cell array of strings, where each string is a line of that file. Then look for lines containing the substring 'EditorMRU':

y = x(~cellfun(@isempty, strfind(x, 'EditorMRU')));

I don't know how many recent file names are stored, though.



来源:https://stackoverflow.com/questions/28587501/recover-a-longer-list-of-recent-files-from-the-matlab-editor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!