next up previous
Next: Comparison to Fortran and Up: Waves Previous: MATLAB as a calculator

Arrays in MATLAB

The most important initial concept to understand in MATLAB is that MATLAB is heavily based on the concept of arrays and matrices.

In MATLAB you can define a one-dimensional array explicitly using the syntax a=[1., 2., 3.] . The rectangular brackets tell MATLAB you wish to make an array. A shorthand notation is a=1:3.

To define a 3 by 3 matrix, you can similarly use mymatrix = [1., 2., 3.; 4., 5., 6.; 7., 8., 9.] Note that commas separate the columns, and the rows are separated by semicolons. The 2,3 element of the is matrix is accessed as mymatrix(2,3).

Often it is convenient to have MATLAB create a list for you. To create 30 points between 0 and 2 tex2html_wrap_inline383 , one can say pointlist=linspace(0, 2*pi, 30).





VICTOR W SPARROW
Tue Feb 25 21:24:33 EST 1997