how to exclude, or remove, input response from command history?

7 views (last 30 days)
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?

Answers (2)

Image Analyst
Image Analyst on 1 Feb 2018
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 Comments
Dave
Dave on 3 Feb 2018
Yes, it is possible to manually remove the "input()" responses from the "Command History" -- but it requires manipulations after the fact. It just seems to me that responses to "input()" are not really 'commands' at all and should not automatically be saved in the "Command History" or we should be able set this as a preference.
Maybe there is no mechanism to alter this behavior, but that is what I was asking about.
Image Analyst
Image Analyst on 3 Feb 2018
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.

Sign in to comment.


Jan
Jan on 31 Jan 2018
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 Comments
Jan
Jan on 3 Feb 2018
Mathworks can provide links, or a mention, of the "dlg"
functions in the help for "input()" as alternatives.
See doc input, in the "See also" line at the bottom, where inputdlg is mentioned. These "See also" hints are very useful to find a matching Matlab command.
Image Analyst
Image Analyst on 3 Feb 2018
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.

Sign in to comment.

Categories

Find more on Entering Commands in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!