MATLAB Basics
MATLAB Basics
MATLAB Basics
Basics
MATLAB User Environment
Workspace/Variable
Inspector
Command Window
Command History
Getting help
There are several ways of getting help:
>> helpdesk
System Environment
• Windows
– MATLAB installed in c:\matlab6.5
– Your code…anywhere convenient (e.g. h:\matlab)
x y
whos : lists names and basic properties of variables in the workspace
>> whos
Name Size Bytes Class
D:\
>> cd cw96\jun02
>> dir
. 30m_wtv.mat edson2km.mat jun02_30m_runs.mat
.. 960602_sst.mat edson_2km_bulk.mat
VARIABLES
• Everything (almost) is treated as a double-
precision floating point array by default
– Typed variables (integer, float, char,…) are
supported, but usually used only for specific
applications. Not all operations are supported for all
typed variables.
– [IDL uses typed variables, but allows mixing of
types...at least to some extent]
>> x=[1 2 3] When defining variables, a space or
x = comma separates elements on a
1 2 3 row.
>> x=[1,2,3]
x =
1 2 3
x =
1
2
3
4
• 1 & 2D arrays are treated as formal matrices
– Matrix algebra works by default:
>> a.*b
??? Error using ==> times
Size and shape must match
Matrix dimensions must agree.
>> a=[1 2] No trailing semicolon,
A = immediate display of result
1 2
>> mean(A)
ans =
4 5 6
>> sum(A)
ans =
12 15 18
INDEXING ARRAYS
n
>> A(2,3)
ans =
6