4

Context: I usually work with MATLAB (R2020a) in -nodesktop or -nodisplay mode on Linux. My command history always gets saved to history.m under my prefdir() when MATLAB exits. The problem is that this file cannot grow above some 4kB or so (rounded down to an integer command count), and I really would like to have more history persist across sessions.

The newer History.xml does not suffer from this limitation, but it only seems to be written to (or read from) when running the full Desktop interface in all its glory.

I found an Answers entry (https://www.mathworks.com/matlabcentral/answers/164147) where a staff member mentions something about an "old implementation of the -nodesktop history [which] has a 4kB limit," but that post is 8 years old now. Has something changed in the meantime? Has anyone had any luck increasing the maximum history size in -nodesktop mode?

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Vicky
  • 969
  • 1
  • 11
  • 19
  • Did you try the [diary](https://es.mathworks.com/help/matlab/ref/diary.html) function like a workaround to log the command window? – josSan Sep 23 '22 at 08:26
  • It´s possible to parse the command window from bash like is commented in the answer of this question [link](https://stackoverflow.com/questions/73126444/how-to-pass-integers-and-strings-from-matlab-to-a-powershell-script/73133338#73133338) – josSan Sep 23 '22 at 08:38
  • I _could_ use `diary`, but then I would have to check that none of my routines call it, as nested diary files are not supported. (At the very least, calls to `diary` would need to be wrapped in some code to check `get(0,'DiaryFile')` and `get(0,'Diary')` and restore the original state afterwards.) System-level approaches (`logrotate(8)` comes to mind) also have their drawbacks. But the main issue with these approaches is that when I open MATLAB again, the new session will not be able to recall the extended command history in any case. – Vicky Sep 23 '22 at 17:05
  • I have run some tests and apparently MATLAB only reads up to 4096 bytes' worth of history (and that is including the appended timestamp of the new session), after LF characters are internally converted to CR+LF pairs. Or LF+NUL, I don't really know. – Vicky Sep 23 '22 at 17:17

0 Answers0