Cell arrays
Cell arrays provide a way to combine a mixed set of objects (e.g., numbers, characters, matrices, other cell arrays) under one variable name.).
Example
>> A = [ 1 2 3 ] A = 1 2 3 >> A(4) = 4 A = 1 2 3 4 >> A(5) = 'hello' % this will produce error ??? In an assignment A(I) = B, the number of elements in B and I must be the same.
The problem in A(5) is that A is an integer array and we are trying to insert character element in it. So this problem can be handled with cell arrays as :
Example
>> C{1} = 1 % note the {} (curly braces) C = [1] [2] >> C{2} = 2 C = [1] [2] >> C{3} = 3 C = [1] [2] [3] >> C{4} = 'Hello' % string is ok now C = [1] [2] [3] 'Hello' >> C{5} = {1 2; 3 4} % appending an array to C C = [1] [2] [3] 'Hello' {2x2 cell}