Effacer les filtres
Effacer les filtres

How to clear the former command

89 vues (au cours des 30 derniers jours)
Yode
Yode le 8 Juil 2017
Commenté : Mounir Esboui le 26 Mar 2019
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?

Réponses (3)

Image Analyst
Image Analyst le 8 Juil 2017
" 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 commentaires
Jan
Jan le 8 Juil 2017
+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 le 9 Juil 2017
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.

Connectez-vous pour commenter.


Hudson Hornet
Hudson Hornet le 15 Nov 2018
Modifié(e) : Hudson Hornet le 14 Jan 2019
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 commentaire
Mounir Esboui
Mounir Esboui le 26 Mar 2019
Thank you

Connectez-vous pour commenter.


Jan
Jan le 8 Juil 2017
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 commentaires
Yode
Yode le 8 Juil 2017
Modifié(e) : Yode le 8 Juil 2017
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 le 8 Juil 2017
Modifié(e) : Steven Lord le 8 Juil 2017
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 输入命令 dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!