Matlab Command Windows Basic Operations

Return to Matlab Tutorials

Command line works similar to our normal handheld calculator.  You gave it an Input and it performs operations. Also, you can tell you to perform certain actions!

These are some of the actions that you need to learn because they will be used repeatedly.

One interesting thing to note is that you can chose to include or omit the use of semicolon 

Inclusion of ; will not display the result of command in command window

Omission of ; will surely display the result of command.

Result could be either a variable value, matrix, graph, image or a video.

disp(‘Hello World!’)

You guessed it right! It shows the world famous Hello World of Matlab.


This command clears the command window. It does no harm to the variables and values saved in your workspace. Instead, it simply clears the window for you. Similar to clearing your desk space while your books are safe in the book shelf 😀


This sucker clears all the variables that you have saved in the workspace. Use carefully as it has messed up many people’s progress.


So you have 100 fancy plots made using various scripts and you want to clear the plots? This is where it comes handy. Run clf in command window and all the plots will be cleared.

 close all

This closes all the windows that you have opened using your program in Matlab. For example, it will close all plots, images, graphs, etc.


doc <function>

This is the best feature of Matlab. Lets suppose you want to know what the frigging “:”  does in Matlab. Simply type doc : in matlab and it will show you help about it.

% (used for comments)

For example, “% clear all” will  make your program ignore that line of code. Best used using Shortcut CTRL+R.

format short and format long

If you wish to change the command window output to smaller or longer decimal places, you can use this command like this.


Return to Matlab Tutorials