Retrieve a variable previous value in the console
13 ビュー (過去 30 日間)
古いコメントを表示
Hello Guys, an easy question. Does anybody know a trick to recover a previous variable value in the console. Lets say that a variable has a stored value (a=3 - it may be a very long vector, matrix, etc and any value) and then it is modified (accidentally) to a new value (a=4). Is there any way to recover the previous value that the variable a had stored? i) immediately after screw it over, something link an undo, ii) after some console commands. Cheers,
2 件のコメント
Guillaume
2019 年 9 月 1 日
If what get fixed? If you're talking about the behaviour described in the question, it's not going to get fixed as there's nothing to fix. This is the way computers behave. Once you put something in memory, it replaces whatever was there previously. Keeping the previous value around would mean storing the previous value somewhere else, making your computer twice as slow while letting you use only half its memory.
回答 (3 件)
Walter Roberson
2013 年 6 月 13 日
Sorry, no, other than starting over or (if you know the values) assigning the values back by hand.
0 件のコメント
Iain
2013 年 6 月 13 日
It may still be in the command history. If so you just need to look at the command history, and drag, (or select and hit enter or copy + paste) the lines of code into your command window and hit enter.
The up cursor button will go through it line by line - handy for something like b = areallylongfunctionname('areallylongpath, ... ... .. ... ,2);
1 件のコメント
Walter Roberson
2013 年 6 月 13 日
Also if you type the first few letters of a command and up-arrow then it will take you back to the command that starts with what you typed.
Leonabil
2013 年 6 月 14 日
1 件のコメント
Walter Roberson
2013 年 6 月 14 日
Sorry, no, once you overwrite a variable it is gone. There is no UNDO for an assignment.
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!