Search code examples
matlabworkspacecommand-window

Is there a command or a way to clear workspace and command window at the same time?


I feel a little troublesome to enter the clear command to clear the workspace, and then enter the clc command to clear the command window.

Is there a command or a way to clear the workspace and the command window at the same time?


Solution

  • There is not a built-in function to do both of these things at once.

    Thankfully you can easily script this behavior by creating a script on your path that calls the commands that you want. For example, you could name your script clr.m and give it the following contents

    clr.m

    clear all;
    clc;
    

    If your intention is to completely clear everything, something like nuke (disclaimer: I am the developer) may be better suited to your needs as it is more complete.