# Starting and Quitting MATLAB

To start MATLAB on a Microsoft Windows platform,

• Double-click the MATLAB shortcut icon on your Windows desktop.
• select the Start -> Programs -> MATLAB R2010a -> MATLAB R2010a
• The shortcut was automatically created by the installer.
• If you start MATLAB from a DOS window, type MATLAB at the DOS prompt.
• After starting MATLAB, the MATLAB desktop opens as shown in figure. 1.

Note: All of the desktop components that were open when you last shut down MATLAB will be opened on startup.

If you already know C, a lot of MATLAB code will be familiar to you. The main advantage of MATLAB over C when doing numerical calculations is that MATLAB is interpreted. That is, you can see the result of one command before you continue on to the next one, unlike C where you must compile the source each time you make a change.

### Startup Directory for MATLAB

The startup directory is the current directory in MATLAB when it first starts, and depends on your platform and installation. You can specify a different startup directory. Startup file is executed when the MATLAB is started/ initiated.

Startup Directory on Windows Platforms

On Windows platforms, when you installed MATLAB, the default startup directory was set to $MATLABroot/work, where$MATLABroot is the directory where MATLAB files are installed.

Startup Directory on UNIX Platforms

On UNIX platforms, the initial current directory is the directory you are in on your UNIX file system when you start MATLAB.

Changing the Startup Directory

You can start MATLAB in a different directory from the default. The directory you specify will be the current working directory when MATLAB starts.

For Windows Platforms Only

To change the startup directory on Windows platforms: Right-click the MATLAB shortcut icon and select Properties from the context menu. The Properties dialog box for MATLAB.exe opens to the Shortcut page. Enter the new startup directory in the Start in field and click OK. The next time you start MATLAB using that shortcut icon, the current directory will be the one you specified in step 2. You can make multiple shortcuts to start MATLAB, each with its own startup directory, and with each startup directory having different startup options

### Quitting MATLAB

• By selecting/clicking (X) right most corner of the window.
• select File -> Exit MATLAB in the desktop
• Or type quit/exit in the Command Window
• You can run a script file named finish.m each time MATLAB quits that, for example, executes functions to save the workspace, or displays a quit confirmation dialog box.

Note: When you close the MATLAB without closing editor window, then when you start again, previous editor windows will be opened by default.

YouTube Video Starting and Quitting MATLAB

## MATLAB Desktop

When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following illustration shows the default desktop as shown in Figure 1. You can customize the arrangement of tools and documents to suit your needs. For more information about the desktop tools, see Desktop Tools and Development Environment.

Figure 1. Default window of the MATLAB when you start

• In command window

>> 2+5
ans =
7
>> a=10
a =
10
>> b=50
b =
50
>> a+b
ans =
60
>> c=a*b
c =   500

### MATLAB Windows

In MATLAB, in the table the first four out of seven windows are extensively used and are listed below Table (1)
Table (1)

 Description of window Window Command window · It’s a main window · Enters the variables ·  Runs the program ·   Open the programs Editor window · Where we write programs using commands. i.e create and debug the script and function files ·  file->new->M-file Figure window· Representing results (output) in graphical form. >> figure >> t=0:0.01:100; >>plot(t, sin(t)) Help window.It provides complete information about the MATLAB >>help     (or) >> doc help >>help toolbox (help simulink) >>help topic ( help graph2d) >>help command (help sqrt) >> doc command (doc sqrt) >> doc topic (doc simulink) >>doc command (doc sqrt) Current directory·   Shows all files in the current directory ·   The file where you are working Workspace windowProvides the information of current variables used by you with Name, value, type Min and Max, Command historyLogs the commands in command window in the date and time format Launch pad WindowProvides the access to Toolboxes, SIMULINK, demos etc.,

### Working with Command window

This is a main window where simple commands, programs can be executed as shown in Figure (2). User defined programs can be opened and can be modified as per the requirements.

Notes for working in the Command Window

• To type a command the cursor | must be placed next to the command prompt (>>).
• Once a command is typed and the Enter key is pressed, the command is executed. However, only the last command is executed. Everything executed previously is unchanged.
• Several commands can be typed in the same line. This is done by typing a comma between the commands. When the Enter key is pressed the commands are executed in order from left to right.
• It is not possible to go back to a previous line in the Command Window, make a correction, and then re-execute the command.
• A previously typed command can be recalled to the command prompt with the up-arrow key ( ).When the command is displayed at the command prompt, it can be modified if needed and executed. The down-arrow key ( ) can be used to move down the previously typed commands.
• If a command is too long to fit in one line, it can be continued to the next line by typing three periods … (called an ellipsis) and pressing the Enter key. The continuation of the command is then typed in the new line. The command can continue line after line up to a total of 4096 characters.

Figure 2. Command window

Start a MARLAB and define A=10; a=5; B=6; b=15, Compute +,-,* (multiplication) ,/(left didision), \ (right division).

### Getting Help

The most useful command in MATLAB is help. This brings up a description of the command you are asking help for. An example of this is:

>> help det DET   Determinant.   DET(X) is the determinant of the square matrix X.     Use COND instead of DET to test for matrix singularity.     See also COND. Overloaded methods   help sym/det.m

All examples in this document will have two greater than symbols followed by a command which can be cut and paste into your version of MATLAB.

Note in the above example, it is asked for help on det and instead, the help page indicates that you should use DET(X). This is explained by the following line from help help

Note: In the online help, keywords are capitalized to make them stand out. Always type commands in lowercase since all command and function names are actually in lowercase.Example: >> help for FOR   Repeat statements a specific number of times.The general form of a FOR statement is:         FOR variable = expr, statement, …, statement END

When asking for help for operators, for example, +, .*, or ‘, MATLAB will bring up a help page which looks like:

>> help +