Member-only story
Cell Arrays
Cell arrays are similar to regular arrays in that they are "indexed" lists of data with a symbolic name. Unlike traditional arrays, a cell array can contain a different data type in every "bucket." These buckets are called "cells." Generally, it is better to use the "structure" data type instead of cell arrays. One of the few times cell arrays are useful (and in fact required) is when an array of strings is created.
Cell Arrays
Cell arrays are used when elements of differing types must be stored in a single array. There is usually not a good reason to do this. If you want multiple "types" of data associated with a single entity, you should use "structures.".
Cell Array Syntax
Cell arrays in Matlab use the curly bracket {} notation instead of the normal parentheses (). While you may think that using () works, it in fact returns the "cell" of the array, not the "value" of the cell, which 99% of the time is not what you are looking for.
Here is an example of creating a cell array one "bucket" (or cell) at a time:
Here is an example of creating the same cell array on a single line:
names = {'jim', 'joe', 'jane', 'janet'};
Warning: using [ ] instead of { } will cause the following (sometimes useful) behavior, which is not what we…