next up previous
Next: Array calculations Up: Arrays in MATLAB Previous: Arrays in MATLAB

Comparison to Fortran and C

You may see a similarity between the syntax of MATLAB and Fortran, if you are familiar with Fortran. A long time ago, MATLAB was a shareware library of Fortran routines. Thus an N length array called xarr in MATLAB goes from xarr(1) to xarr(N), exactly as Fortran notates arrays. Similarly the 4,2 element of a MATLAB matrix ymat is given as ymat(4,2) as in Fortran.

For those of you who are proficient in the programming language C or its derivatives such as C++, you know that arrays and matrices are quite different in C. In C an N length array xarr goes from xarr[0] to xarr[N-1], using square brackets instead of parentheses. Also in C the 4,2 element of a matrix ymat is accessed as ymat[3][1]. MATLAB does not understand this type of syntax.

Tue Feb 25 21:24:33 EST 1997