필터 지우기
필터 지우기

Retrieve a variable previous value in the console

조회 수: 12 (최근 30일)
Leonabil
Leonabil 2013년 6월 13일
댓글: Guillaume 2019년 9월 1일
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
Craig
Craig 2019년 9월 1일
hope this gets fixed
Guillaume
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
Walter Roberson 2013년 6월 13일
Sorry, no, other than starting over or (if you know the values) assigning the values back by hand.

Iain
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
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
Leonabil 2013년 6월 14일
Thanks for your answers. The problem is that I do not have available the command and the numerical value on the variable. Indeed, the variable is a matrix array resulting of a very long iteratively optimisation problem lost by typing mistake. Then, getting back in the command history unfortunately does not work, so I was wondering if Matlab has something linke a variable repository memory where I can recover a previous variable value not recurring to the command history or manual entry :-( I am afraid that I need to run the whole process again and this time save the variable - just in case. Thanks for your answers.
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 6월 14일
Sorry, no, once you overwrite a variable it is gone. There is no UNDO for an assignment.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by