フィルターのクリア

How to clear the former command

89 ビュー (過去 30 日間)
Yode
Yode 2017 年 7 月 8 日
コメント済み: Mounir Esboui 2019 年 3 月 26 日
Of course,we know the function clc will clear all input command.But sometimes,I just want to clear the former one command or former two,but not former all.Is this possible?

回答 (3 件)

Image Analyst
Image Analyst 2017 年 7 月 8 日
" when I make some typo in the second command.I should re-type all command..So if I can delete previous one or two,it will make my life easier."
Learn how to write a script. You can't progress in MATLAB just doing everything from the command line all the time. Then, your "question" will no longer be a problem. Simply run your script again.
If you really want to remove something prior that you typed on the command line from the history, then type up arrow (to reveal the history) then, right click on the prior command that you want to remove from the history list, and select "Cut". It will no longer appear in the history. (I know, I just tried it and verified that.)
  2 件のコメント
Jan
Jan 2017 年 7 月 8 日
+1: a) A script or function will be much better than collecting commands in the command window. b) the right click in the command history (not in the command window) works - but see a) for a better solution.
Image Analyst
Image Analyst 2017 年 7 月 9 日
You can see the history as a popup window in the command window (like my Answer above), or in it's own docked history window. To clarify...
To view the command history, press the up-arrow key, ↑, in the Command Window. To retrieve a command using a partial match, type any part of the command at the prompt, and then press the up-arrow key. You can right click inside this popup history window nested inside the command window to delete the item from the history.
To dock or detach the Command History window, click , and then select an option. To view the Command History if it is closed: on the Home tab, in the Environment section, click Layout. Then, under Show, click Command History and select either Docked or Popup.

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


Hudson Hornet
Hudson Hornet 2018 年 11 月 15 日
編集済み: Hudson Hornet 2019 年 1 月 14 日
There is one interesting way. Go to Preferences > Command History.
You'll be able to set Save last X commands. If you set it to 10 and apply, it'll remove all except last 10 commands. Then you can set it back to default (25,000 with my release - 2018a) or anything you want.
  1 件のコメント
Mounir Esboui
Mounir Esboui 2019 年 3 月 26 日
Thank you

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


Jan
Jan 2017 年 7 月 8 日
clc does not clear "the input", but the output to the command window. This might look nitpicking, but the difference might concern the question. Note that the output is not securely deleted, but it vanishes from the display in the command window only.
What is the purpose of removing one or two "commands" from the command window? You could try to do thisusing the methods included in FEX: CmdWinTool, see the comments in the "getText" method. Unfortunately all my trials ended with a crash. I stopped further investigations, because modifying the output to the command window is too awkward at all. The command window is not the correct locations for smart tricks. Therefore I suggest to think twice, if your aim can be achieve directly in a much cleaner way.
  2 件のコメント
Yode
Yode 2017 年 7 月 8 日
編集済み: Yode 2017 年 7 月 8 日
I'm studing Matlab,I try to make some screenshoot note(include three or more command).But when I make some typo in the second command.I should re-type all command..So if I can delete previous one or two,it will make my life easier.
Steven Lord
Steven Lord 2017 年 7 月 8 日
編集済み: Steven Lord 2017 年 7 月 8 日
If you want to do this so you can simply copy and paste the output from the Command Window into a report or something like that, consider writing a script file (as others have suggested) or logging the Command Window output to a file using the command diary then prune the diary file to only include the output you want to report.
There's also the possibility of using the Live Editor, where the output will appear in the script file itself.

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

カテゴリ

Help Center および File Exchange输入命令 についてさらに検索

Community Treasure Hunt

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

Start Hunting!