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 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:

         
        names{1} = 'jim'; 
        names{2} = 'joe'; 
        names{3} = 'jane'; 
        names{4} = 'janet'; % notice the use of the curly brackets {} 
Posted on by