# Connexions

You are here: Home » Content » What is MATLAB?

### Recently Viewed

This feature requires Javascript to be enabled.

# What is MATLAB?

Module by: Serhat Beyenir. E-mail the author

Summary: A brief introduction to MATLAB.

MATLAB stands for MATrix LABoratory (see wikipedia) and is a commercial software application written by The MathWorks, Inc. When you first use MATLAB, you can think of it as a glorified calculator allowing you to perform engineering calculations and plot data. However, MATLAB is more than an advanced scientific calculator, for example MATLAB's sophisticated numerical computation environment also allows us to analyze data, simulate engineering systems, document and share our code with others.

## Why Use MATLAB?

MATLAB has become a defacto standard in many fields of engineering and science. Even a casual exploration of MATLAB should unveil its computational power however a closer look at MATLAB's graphics and data analysis tools as well as interaction with other applications and programing languages prove why MATLAB is a very strong application for technical computing.

The standard MATLAB installation includes graphics features to visualize engineering and scientific data in 2-D and 3-D plots. We can interactivity build graphs and generate MATLAB command output that can be saved for use in the future. The saved-instructions can be called again with different data set to build new plots. The plots created with MATLAB can be exported in various file formats (e.g. .jpg, .png) to embed in Microsoft Word documents or PowerPoint slideshows.

MATLAB also contains interactive tools to explore and analyze data. For example, we can visualize data with one of the many plotting routines, zoom in to plots to take measurements, perform statistical calculations, fit curves to data and evaluate the obtained expression for a desired value.

MATLAB interacts with other applications (e.g. Microsoft Excel) and can be called from C code, C++ or Fortran programming language.

## Running MATLAB

To use MATLAB, it must be installed on your computer and you can start it just like you start any application on your system or you must have access to a network where it is available.

In POWR 3307, we will use MATLAB by accessing the BCIT network. The network access is platform independent, that is, we can run MATLAB under Mac OS X or Microsoft Windows operating systems through a web browser. The following links provide instructions on how to access and use BCIT's AppsAnywhere service:

How to access AppsAnywhere with Safari on a Macintosh Computer

How to open and save files in AppsAnywhere when logging in from a Macintosh

How to access AppsAnywhere using Firefox

## The MATLAB Desktop

When you start the MATLAB program, it displays the MATLAB desktop. The desktop is a set of tools (graphical user interfaces or GUIs) for managing files, variables, and applications associated with MATLAB. The first time you start MATLAB, the desktop appears with the default layout, as shown in the following illustration.

### Command Window

The Command Window is where we execute MATLAB commands. We enter statements at the Command Window prompt. The prompt can be any one of the following:

• Trial>> indicates that the Command Window is in normal mode and the MATLAB license will expire after the trial period ends.
• EDU>> indicates that the Command Window is in normal mode, in MATLAB Student Version.
• >> indicates that the Command Window is in normal mode.

### Command History

The Command History is a log of the commands we have executed in the command window.

### Workspace

The workspace consists of a set of variables stored in memory during a MATLAB session. To open the Workspace browser, select Desktop > Workspace in the MATLAB desktop, or type

>> workspace

at the Command Window prompt.

### Current Folder

The Current Folder is like the Finder in Mac OS X or Windows Explorer in Windows operating systems and allows us to browse through the files and folders. The Current Folder also displays details about files in your current directory and within the hierarchy of the folders it contains.

### Start Button

The MATLAB Start button is located at the lower left corner of the MATLAB desktop and provides and easy access to tools, demos, and documentation for the MATLAB installation.

The menu bar contains commands for creating, opening, printing, editing, viewing, and manipulating desktop items.

### Toolbar

The MATLAB toolbar provides on-screen buttons to access frequently used features such as, copy, paste, undo and redo.

### Keyboard shortcuts

MATLAB provides keyboard shortcuts for viewing a history of commands and listing contextual help.

1. The up arrow key,
2. The tab key,
3. The semicolon symbol.

#### The Up Arrow Key

Suppose we want to enter the following equation:

>> y=sin(45)

But we mistakenly entered

>> y=sine(45)

MATLAB returns the following prompt:

??? Undefined function or method 'sine' for input arguments of type 'double'.

Instead of retyping the equation, press the up arrow key, the mistakenly entered line is displayed. Using the left arrow key, move the cursor to the misspelled letter. Make the correction and press Return or Enter to execute the command.

Pressing the up arrow key repeatedly recalls the previously entered commands. Likewise, typing the first characters of previously entered line and pressing the up arrow key displays the full command line. To execute that line, simply press the Return or Enter key.

#### The Tab Key

Suppose you forgot how to enter the square root command. Begin typing y=sq in the command prompt:

>> y=sq

Then press the tab key and scroll down to sqrt. Select it and press Return or Enter key.

>> y=sqrt

#### The Semicolon Symbol

The semicolon symbol at the end of a line suppresses the screen output. This is useful when you want to keep your command window clean.

Type the following entry and press the Return key:

>> y=2+2

The following output is displayed:

y =

4

Now, press the up arrow key to recall our initial entry

>> y=2+2

And insert a semicolon as follows:

>> y=2+2;

No numerical result is displayed however MATLAB stores the value of y in the memory. We can recall the value y by simply typing y and pressing Return.

## MATLAB Help

MATLAB comes with three forms of online help: help, doc and demos.

### Help

Typing help in the Command Window lists all primary help topics. You can display a topic by clicking on the link.

>> help

Or if you know the command or function you need help with, you can type help followed by the command or function. For example to learn about clc command, type help clc at the command prompt:

>> help clc

Also try the following command:  >> help clear

To learn about sine function, type  help sin at the command prompt:

>> help sin

### Doc

Obviously, to use help effectively, you need to know what you are looking for. Often times, especially when you first start learning an application, it is usually difficult to ask the right questions. In the case of MATLAB, doc command is generally better than help. If you type doc in the command prompt, MATLAB opens a browser from where you can obtain help easier:

>> doc

Like using  help sin, try typing doc sin in the command prompt:

>> doc sin

### Demos

You can learn more about MATLAB through demos by typing demo in the command prompt, a list of links to demos will open in Help Browser. Demos and online seminars are available at product demos and online seminars.

>> demo

## Useful Commands and Functions

For a detailed explanation and examples for each of the following type ‘help function’ (without quotes) at the MATLAB prompt.

Table 1: Useful commands and functions
Command/Function Meaning
clc Clear Command Window
clear Remove items from workspace
who, whos List variables in workspace
workspace Display Workspace browser
cd Change working directory
pwd Display current directory
computer Identify information about computer on which MATLAB is running
ver Display version information for MathWorks products
quit Terminate MATLAB
exit Terminate MATLAB (same as quit)

## Summary of Key Points

1. MATLAB is a popular technical computing application and MathWorks offers a trial version of MATLAB on their website,
2. The MATLAB Desktop consists of Command Window, Command History, Workspace, Current Folder and Start Button,
3. The up/down arrow keys, the tab key and the semicolon are convenient tools to use the Command Window,
5. Various commands and functions make MATLAB experience easier, for example, clc, clear and exit.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks