MATLAB Answers

Working backwards from a command window

1 view (last 30 days)
Alex
Alex on 15 Apr 2013
Hey all, I had a strange question that I couldn't find an answer for, perhaps I could get some help here?
A friend of mine was working on an m file for an assignment, and had been executing it to see the results. After deleting the trash on her user account, the m file vanished from the harddrive, but all the outputs from the execution of said m file remained in the command window, which brings me to the question:
Is it possible to use Matlab to work backward from the results in the command window to recover the commands from the m file? Since Matlab was dependent on those commands to generate the output I mean. I also am not looking for an intuitive 'you can see the output, so you can manually discern the m file's contents' type solution.
I hope that makes sense?
--Alex--

Accepted Answer

Jan
Jan on 15 Apr 2013
Edited: Jan on 15 Apr 2013
No, this will not work in general.
An exception would be, if a echo on all enabled the display of all processed code during the program runs. But without this there is no chance to use the output to the command window to decide, which code has created this output. Example:
% Command window:
2
% Possible codes:
x = [pi, sin(1.234)];
fprintf('%d\n', length(x))
% Or:
x = clock;
fprintf('%d\n', x(5))
And this is a very trivial example only.
But it would be trivial to reconstruct the deleted file in the leven of the operating system. Deleting does not overwrite the biots on the harddisk, but removes the point in the file system table only.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!