command history with updates

8 次查看(过去 30 天)
Roy Torbert
Roy Torbert 2019-12-18
移动Fangjun Jiang 2025-1-28
How do I import my command history from a previous release, once I have installed a new one ?
  4 个评论
Roy Torbert
Roy Torbert 2019-12-20
Is there an answer to my question ?
Fangjun Jiang
Fangjun Jiang 2019-12-20
I suggested below. Did you try?

请先登录,再进行评论。

回答(2 个)

Fangjun Jiang
Fangjun Jiang 2019-12-18
The command history is saved as history.xml for different versions. See if you can simply copy over the file.
C:\Users\XYZ\AppData\Roaming\MathWorks\MATLAB\R2019b\History.xml
C:\Users\XYZ\AppData\Roaming\MathWorks\MATLAB\R2018b\History.xml
  5 个评论
Walter Roberson
Walter Roberson 2025-1-26
移动:Fangjun Jiang 2025-1-28
Pallication Support
I think you mean Application Support
Fangjun Jiang
Fangjun Jiang 2025-1-27
移动:Fangjun Jiang 2025-1-28
Wow, took more than 5 years to discover a typo! What are you doing? I am curious.

请先登录,再进行评论。


Matt Stead
Matt Stead 2025-1-26
编辑:Matt Stead 2025-1-26
I wote this function, which works, but the history is not updated until Mtalb is relaunched. So this is part answer and part question. If anyone knows how to get Matalb to reload the history file without relaunching, I would love to know. Here is my function:
function append_history(cmd, exec_time)
% exec_time is in microseconds
% tic; <command>; exec_time = round(toc * 1e6);
hist_path = fullfile(prefdir,'History.xml');
if (exist(hist_path,'file'))
% read history file
txt = fileread(hist_path);
% condition cmd
if (isstring(cmd))
cmd = char(cmd);
end
len = length(cmd);
if (cmd(len) ~= ';')
cmd(len + 1) = ';';
end
% build xml history entry
xml_cmd = ['<command execution_time=' '"' num2str(exec_time) '">' cmd '</command>' newline];
new_txt = insertBefore(txt, '</session>', xml_cmd);
% write out file
fp = fopen(hist_path, 'w');
fwrite(fp, new_txt, 'char');
fclose(fp);
else
beep
fprintf(2, 'File not found: ''History.xml''\n');
disp('Cannot update history.');
return
end
end

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by