Docsity

MATLAB Data Types: Understanding Variables, Values, Locations, and Data Types - Prof. Joh , Study notes of Computer Science

Toggle sidebar
bg1
COMP 116
27 Aug 2007
MATLAB data types
A variable in MATLAB as in most programming languages, comes with three things:
a value:
a location:
and a data type:
From the MATLAB help "Overview of Data
Types":
Which are most important to us?
What's the difference between
single & double?
How do these commands use/change locations, values, & types?
a*b
newvariable = 6.023e23
a = a + 1
a = 3b
(Array operations)
brackets []
semicolon ;
colon :
transpose '
indexing ()
math + - * / ^ sqrt() sin() sum() round() floor() ceil()
array math .* ./ .^
rc array creation zeros(r,c) ones(r,c) rand(r,c)
graphing/plotting plot() hist()
How do you:
find how many spots on one die? two dice? 5 dice?
throw 5 dice 1000 times and plot the number of spots each time? plot a histogram?

Partial preview of the text

Download MATLAB Data Types: Understanding Variables, Values, Locations, and Data Types - Prof. Joh and more Study notes Computer Science in PDF only on Docsity!

COMP 116

27 Aug 2007 MATLAB data types A variable in MATLAB as in most programming languages, comes with three things: a value: a location: and a data type: From the MATLAB help "Overview of Data Types": Which are most important to us? What's the difference between single & double? How do these commands use/change locations, values, & types? ab newvariable = 6.023e a = a + 1 a = 3b (Array operations) brackets [] semicolon ; colon : transpose ' indexing () math + - * / ^ sqrt() sin() sum() round() floor() ceil() array math . ./ .^ rc array creation zeros(r,c) ones(r,c) rand(r,c) graphing/plotting plot() hist() How do you: find how many spots on one die? two dice? 5 dice? throw 5 dice 1000 times and plot the number of spots each time? plot a histogram?