how to exclude, or remove, input response from command history?
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a function that uses "input()" to get a user response. Is there a way to not record the value returned from "input()" in the command history? Alternatively, is there a way to "remove" the response from the command history?
in the command window I get:
select this line (s to select, d for done, c for clear) : c
rply =
'c'
select this line (s to select, d for done, c for clear) : s
rply =
's'
select this line (s to select, d for done, c for clear) : d
rply =
'd'
or if I suppress the display of "rply" by inserting a semicolon in the code the command window is:
select this line (s to select, d for done, c for clear) : c
select this line (s to select, d for done, c for clear) : s
select this line (s to select, d for done, c for clear) : d
In either case, the command history shows:
inspect_outliers_test(1)
c
s
d
inspect_outliers_test(1)
c
s
d
What I would like to do is suppress, or remove, the user typed response ("rply" value) from the command history. The reason is that there may be many user responses generated inside a loop and it just clutters up my command history. It would be nice if there was a setting to toggle the saving of user input (via "input()") in the command history, but I have not been able to find it.
Any suggestions?
댓글 수: 0
답변 (2개)
Image Analyst
2018년 2월 1일
To remove commands you have run from your command history, click on the command window prompt and hit the up arrow. Then scroll up to the command you no longer want to show up and right click on it. Select "delete" and it will no longer appear in your command history.
Alternatively you can remove it from the History.xml file manually with a text editor. If you have Windows, edit the file "C:\Users\yourName\AppData\Roaming\MathWorks\MATLAB\R2017b\History.xml" with something like Notepad, and delete the lines you don't want in your history.
댓글 수: 2
Image Analyst
2018년 2월 3일
Maybe but I don't know how to do it. And generally I don't care what goes into my history log. If you do, then call the Mathworks - maybe there is a way to turn off the history in code. As you can see from the preferences, there is a way to turn it off from the dialog box.
Maybe you can turn it off prior to calling input() and turn it back on after you call input().
You might find an answer from Yair's undocumented MATLAB site: https://undocumentedmatlab.com/blog/changing-system-preferences-programmatically or just ask the Mathworks directly.
Jan
2018년 1월 31일
Do not use the command history for complicated user defined logging. This is not its purpose. If you want to log data, creating a dedicated log file is more secure and efficient. Using input to insert data makes it much harder to impossible to reproduce your results. Better create a GUI or define the input data as files or by code, such that they can be provided as input arguments. Then recording the values is much easier and you do not have to try any tricks to manipulate the command window history.
댓글 수: 5
Image Analyst
2018년 2월 3일
If it really bugs you, you can make an m-file called filter_history.m where you open the history.xml file, extract out only the items you want, write out out to a temporary file, delete the original history file, and rename the temporary file to history.xml. You could put the call to that filter_history function in your startup.m file. Of course it would remove only the undesired functions up to the present session, not those in the present session.
참고 항목
카테고리
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!