The Van der Pol oscillator, with the parameter μ set to 5, is a mildly stiff differential equation. In anticipation, I used the ode23s solver; the ‘s’ in the name indicates that it is for stiff equations. In the plot you can see some clustering of steps where the solution is varying rapidly. A nonstiff solver would have taken many more steps. A stiff ode solver uses an implicit method requiring the solution of a set of simultaneous linear equations at each step. The iconic MATLAB backslash operator is quietly at work here.
Data Types
For many years, MATLAB had only one numeric data type: IEEE standard 754 double-precision floating point, stored in the 64-bit format. As people began to use MATLAB for more applications and larger data sets, we provided more ways to represent data.
Single Precision and Integer
Support for single-precision arithmetic began in the early 2000s and was complete by MATLAB 7 in 2004. Requiring only 32 bits of storage, single precision cuts memory requirements for large arrays in half. MATLAB does not have declarations, so single-precision variables are obtained by executable conversion functions.
MATLAB 7 also introduced three unsigned integer data types, uint8, uint16, and uint32; three signed integer data types, int8, int16, and int32; and one logical data type, logical.
Sparse Matrices
Sparse matrices were introduced with MATLAB 4 in 1992. They are a memory-efficient way to represent very large arrays that have few nonzero values. Only the nonzero elements are stored, along with row indices and pointers to the starts of columns. The only change to the outward appearance of MATLAB is a pair of functions, sparse and full. Nearly all the operations apply equally to full and sparse matrices. The sparse storage scheme represents a matrix in space proportional to the number of nonzero entries, and most of the operations compute sparse results in time proportional to the number of arithmetic operations on nonzeros.
Cell Arrays
Cell arrays were introduced with MATLAB 5 in 1996. A cell array is an indexed, possibly heterogeneous collection of MATLAB objects, including other cell arrays. Cell arrays are created by curly braces, {}.
Cell arrays can be indexed by both curly braces and smooth parentheses. With braces, c{k} is the contents of the k-th cell. With parentheses, c(k) is another cell array containing the specified cells. Think of a collection of mailboxes. box(k) is the k-th mailbox. box{k} is the mail in the k-th box.
Structures
Structures and associated “dot notation” were introduced in 1996. This script for creating a grade book for a small class shows structures and dot notation at work.
Math101.name = ["Alice Jones"; "Bob Smith"; "Charlie Brown"];
Math101.grade = ["A"; "B+"; "C"];
Math101.year = [4; 2; 3];
To call the roll, we need the list of names.
disp(Math101.name)
"Alice Jones"
"Bob Smith"
"Charlie Brown"
Changing Charlie’s grade involves both structure and array notation.
Math101.grade(3) = "W";
disp(Math101.grade)
"A"
"B+"
"W"
Objects
Major enhancements to MATLAB object-oriented programming capabilities were made in 2008. Creating classes can simplify programming tasks that involve specialized data structures or large numbers of functions that interact with particular kinds of data. MATLAB classes support function and operator overloading, controlled access to properties and methods, reference and value semantics, and events and listeners.
The MATLAB graphics system is one large, complex example of the object-oriented approach to MATLAB programming.
Making MATLAB More Accessible: Desktop and Live Editor
The first versions of MATLAB were simple terminal applications. Over time we added separate windows for graphics, editing, and other tools. These gradually made MATLAB easier to use, especially for users without prior programming experience. Two specific features that have had the biggest impact are the desktop and the Live Editor.
Desktop
The MATLAB desktop was introduced in 2000. Here is a screenshot showing how it looks today.