フィルターのクリア

controlling what gets saved in command history

4 ビュー (過去 30 日間)
Dave
Dave 2014 年 7 月 16 日
コメント済み: Dave 2014 年 7 月 18 日
I have a function that asks user (using the "input" function) if they want to enhance a plot and/or print the figure. There are several prompts and response processing steps in the function. My problem is that all the user responses get saved in the command history (along with whitespace lines) making the command history cluttered up with these lines of (usually) 1 character responses to input prompts. Is there a way to turn command history recording on/off (like you can do with "diary")?
I would like to turn command history recording "off" at start of my function and then back "on" at the end of the function to avoid capturing the keyboard input response to the prompt in the command history. Alternatively, but less desirable, can you make the "input" function not echo back the user response?
Any ideas?

回答 (2 件)

Brian B
Brian B 2014 年 7 月 16 日
You could use the method described in this post to disable and enable the history. Unfortunately, it seems that preference only affects what gets saved from one session to the next. Commands entered during the current MATLAB session are recalled regardless of the setting.
  2 件のコメント
Dave
Dave 2014 年 7 月 17 日
thanks, but its really not what I'm looking for. I want something that works in the current session.
Peter Muellers
Peter Muellers 2014 年 7 月 17 日
I can't think of a way to do what you want but I have entered this into our database of possible future enhancements.

サインインしてコメントする。


Jan
Jan 2014 年 7 月 18 日
Alternatively, but less desirable, can you make the "input" function not echo back the user response?
input() does not echo the user response:
disp('before');
reply = input('What is the number? ');
disp('after');
The output ist:
before
What is the number? 90
after
No blank lines, no echo.
The command window is not a good interface for user input. Better create a GUI.
  1 件のコメント
Dave
Dave 2014 年 7 月 18 日
Jan,
I agree that it does not echo back the user response in the command window -- but it does echo the user response in the command history window. Its the command history output I was asking about. In a script, or function, with many user prompts for input (e.g., in a loop) there can be many lines of user responses in the command history -- its nice that identical user responses get aggregated (with a little counter), so maybe the best I can do is try to craft my queries so the user typically supplies the same answer.
PS: using R2014a
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by