You are on page 1of 8

MATLAB For Dummies Cheat Sheet - For Dummies

Advertisement

Search

Recommended for You

10 Medicinal Herbs to
Boost Your Immunity - For
Dummies

Strength-Training Exercise:
The Push-Up - For Dummies

These 25 Dog Breeds Live


The Longest

7 Health Benefits Of Eating


Banana Daily

Promoted by Positive Daily

Promoted by The Busy Wire


Recommended by

See All Topics

Computers & Software

Programming
Advertisement

Ads by Rubicon Project

MATLAB For Dummies


From MATLAB For Dummies by Jim Sizemore,
John Paul Mueller
MATLAB is an incredibly flexible environment that you can
use to perform all sorts of math tasks. A large array of
engineering and science disciplines can use MATLAB to
meet specific needs in their environment. Using such a
complex environment can prove daunting at first, but this
Cheat Sheet can help: Get to know common MATLAB
commands; become familiar with common operators and
precedence; and learn to recognize line plot styles.

Common MATLAB Commands


The following table contains a listing of commands that you use relatively
often in MATLAB. You won't find every command listed that would require
a book in itself. However, these commands are usually used several times
each session.

More Series
C++ All-In-One For Dummies Cheat Sheet
ASP.NET 3.5 For Dummies Cheat Sheet
Windows PowerShell 2 For Dummies Cheat Sheet
PHP & MySQL For Dummies Cheat Sheet
Visual Basic.NET All-in-One Desk Reference For
Dummies Cheat Sheet

Command

Purpose

cla

Clears the current plot

clc

Clears the Command window

clear <variable

Removes a specific variable from the Workspace

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

name>

window (as specified by <variable name>)

clear all

Removes all of the variables from the Workspace


window

name>

Closes a specific figure (as specified by


<figure name>)

close all

Closes all of the current figures

diary <filename>

Specifies the name of the file to use for the Diary


feature

close <figure

Featured Book
MATLAB For Dummies
US $29.99
Add To Cart

More For Dummies


Online Test Banks

diary off

Stops saving the Command window text to a file

Browse Online Courses

diary on

Starts saving the Command window text to a file

Explore Mobile Apps

exist <keyword>

Checks whether a keyword or file is in use

Shop for Books and More

format compact

Removes extraneous spaces from the Command


window

gca

Obtains a handle to the current axes

gcf

Obtains a handle to the current figure

gco

Obtains a handle to the current object

get(<handle>,

Obtains the <property> found in the object

<property>)

pointed at by <handle>

help <command or

Displays help documentation for the <command>

file>

or comments in files you've created

iskeyword

Displays a list of all the MATLAB keywords

iskeyword <name>

Determines whether <name> is a keyword

load <filename>

Loads the file containing variables to the


Workspace window

more off

Displays output using standard scrolling so that


all of the output appears at one time

more on

save <filename>

Tells MATLAB to display output one screen at a


time
Saves the variables shown in the Workspace
window to the specified file

Advertisement

Newsletters
Sign up for one of our newsletters...

Computers, Mobile Devices & Gadgets

Digital Photography

Food, Home & Garden

Health & Wellness

Mac

Microsoft Windows & Office

Online & Social Networking

Personal Finance & Careers


Small Business

set(<handle>,

Sets the <property> found in the object

<property>,

pointed at by <handle> to the specified

enter E-Mail address

<value>)

<value>

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

Privacy Policy

MATLAB For Dummies Cheat Sheet - For Dummies

MATLAB Common Operator Summary


You need to know which operators MATLAB supports, but remember them all
isn't easy. The following table provides a brief summary of the operators that
MATLAB supports.
Operator

Type

Description

Example

Arithmetic

Subtracts the right operand


from the left operand.

5 - 2 = 3

Arithmetic

Multiplies the right operand


by the left operand.

5 * 2 = 10

Arithmetic

Calculates the exponential


value of the right operand by
the left operand.

5^2 = 25

Arithmetic

Divides the left operand by


the right operand.

5 / 2 =

Divides the right operand by


the left operand.

5 \ 2 =

Arithmetic

2.5000

0.4000

Arithmetic

Adds two values together.

5 + 2 = 7

Arithmetic

Modifies operators to
perform element-by-element
arithmetic vis--vis matrix
arithmetic. You receive no
modification if you're
operating on scalars
(ordinary numbers).

[1,2]*[3;4]

Assigns the value found in


the right operand to the left
operand.

MyVar = 2

Assignment

= 11
[1,2].*[3,4]
= [3,8]

results in
MyVar
containing
2

bitand

bitor

bitget

bitset

bitshift

bitxor

Bitwise

Bitwise

Bitwise

Bitwise

Bitwise

Bitwise

Performs a logical and of the

bitand(4,

bits in two numbers.

5) = 4

Performs a logical or of the

bitor(4, 5)

bits in two numbers.

= 5

Obtains the value of the bit


at a specific location.

bitget(4,

Changes the bit at the


specified location.

bitset(4,

Shifts the bits the specified


number of positions.

bitshift(2,

Performs a logical
exclusive or on the bits

bitxor(4,

3) = 1

1, 1) = 5

1) = 4

5) = 1

in two numbers.

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

and

Logical

Determines whether both


operands are true.

and(true,
true) = 1
(or true)
and(true,
false) = 0
(or false)
and(false,
false) = 0
and(false,
true) = 0

not

Logical

Negates the truth value of a


single operand. A true

not(true) =
0

value becomes false and a


false value becomes

not(false)=1

true.
or

Logical

Determines when one of two


operands are true.

or(true,
true) = 1
or(true,
false) = 1
or(false,
false) = 0
or(false,
true) = 1

xor

Logical

Determines when one and


only one of the operands is
true.

xor(true,
true) = 0
xor(true,
false) = 1
xor(false,
false) = 0
xor(false,
true) = 1

all

Logical

Determines whether all the

all([1, 2,

array elements are nonzero


or true.

3, 4]) = 1
all([0, 1,
2, 3]) = 0

any

Logical

Determines whether any of


the array elements are

any([0, 1,
0, 0]) = 1

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

nonzero or true.
any([0, 0,
0, 0]) = 0
~=

Relational

Determines whether two


values are not equal.

1 ~= 2 is 1
(or true)

<

Relational

Verifies that the left operand


value is less than the right
operand value.

1 < 2 is 1

<=

Relational

Verifies that the left operand


value is less than or equal to
the right operand value.

1 <= 2 is 1

==

Relational

Determines whether two


values are equal. Notice that
the relational operator uses
two equals signs. A mistake

1 == 2 is 0

many developers make is


using just one equals sign,
which results in one value
being assigned to another.
>

Relational

Verifies that the left operand


value is greater than the
right operand value.

1 > 2 is 0

>=

Relational

Verifies that the left operand


value is greater than or
equal to the right operand

1 >= 2 is 0

value.
-

Unary

Negates the original value


so that positive becomes
negative and vice versa.

-(-4)
results in
4 while -4
results in
-4

Unary

Provided purely for the sake


of completeness. This
operator returns the same
value that you provide as
input.

+4 results
in a value
of 4

MATLAB Operator Precedence


Knowing the order in which tasks are performed is essential. Otherwise, the
formulas you type won't work as expected and you'll obtain errant results. The
following table shows the order in which MATLAB evaluates various
operators.
You can also remember operator precedence using the PEMDAS
acronym, which stands for Parentheses, Exponent, Multiply And

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

Divide, Add and Subtract.


Operator

Description

()

Parentheses are used to group expressions and to override


the default precedence so that you can force an operation of
lower precedence (such as addition) to take precedence over
an operation of higher precedence (such as multiplication).

.' .^ ' ^

Transpose, power, complex conjugate transpose, matrix


power.

+ -~

Unary operators interact with a single variable or expression.

.* ./

Multiplication and division(both right and left).

.\ * / \
+ -

Addition and subtraction.

Colon operator (used for ranges).

<= < >

Comparison operators.

>=
== ~=

Equality operators.

& |

Logical operators (element-wise).

&& ||

Logical operators (short-circuit).

Line Plot Styles in MATLAB


Whenever you create a plot in MATLAB, you need to identify the sources of
information using more than just the lines. Creating a plot that uses differing
line types and data point symbols makes the plot much easier for other
people to use. The following table contains a listing of the line plot styles.

Color

Marker

Style
Code

Line Color

Code

Marker Style

Code

Line Style

blue

point

Solid

green

circle

Dotted

red

x-mark

-.

dash dot

cyan

plus

--

Dashed

magenta

star

(none)

no line

yellow

square

black

diamond

white

down triangle

up triangle

<

left triangle

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

>

right triangle

5-point star

6-point star

Remember that you can also use these styles with other kinds of
plots. For example, a scatter plot can use these styles to define
each of the data points. When in doubt, try the styles to see whether
they work with your particular plot.

Add a Comment

Print

Share

Recommends
MATLAB Common Operator Summary
10 Amazing MATLAB Add-Ons - For Dummies
Common MATLAB Commands
Ten Things Never to Say or Do in Russia - For Dummies
Unhealthy Foods to Avoid at All Costs - For Dummies

Promoted Stories From Around The Web

How Older Men Tighten


Their Skin

Insane Military Grade


Flashlight Is Flying Off
Shelves

Want to See How


Celebrities Really Live?
See Inside These

Vir3

Mansion Global by Dow Jones

25 Gifts That Every Man

27 Famous People You

6 Common Causes Of

Secretly Wants, My
Boyfriend Totally

Didnt Know Had


Dyslexia.

Halitosis (Bad Breath)

LifeBuzz

LifeBuzz

The Modern Man Today

The Busy Wire

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

MATLAB For Dummies Cheat Sheet - For Dummies

Who Are The Hottest TV

How more time and

How I Learned 9

Commercial Stars?

energy could change


the world

Languages

All About The Buzz

Babbel

Bill Gates

Recommended by

Hiranandani Hyderabad
Plots for Sale Starting at Just 15 Lakhs. Enquire Today.

COMMENTS
blog comments powered by Disqus
Advertisement

About us
About For Dummies
Contact Us
Privacy Policy
Terms and Conditions
Advertise with Us
Manage Your E-Mail
Newsletters
Help

More From
Dummies
Mobile Site
My Account
Dummies B2B Services
Online Test Banks
eLearning
Mobile Apps
Dummies Store
Sweepstakes

Copyright 2016 & Trademark by John Wiley & Sons, Inc. All rights reserved.

http://www.dummies.com/how-to/content/matlab-for-dummies-cheat-sheet.html[3/11/2016 7:38:08 AM]

Topics A-Z
Small Business &
Careers
Computers & Software
Consumer Electronics
Crafts & Hobbies
Education & Languages
Food & Drink
Games
Health & Fitness

Home & Garden


Internet & Social
Media
Music & Creative Arts
Personal Finance
Pets
Photography & Video
Relationships & Family
Religion & Spirituality
Sports & Outdoors