Arrays vs. cells
Let's look at some basic syntax to start with. To create an array with elements a, b, c you write [a b c]
. To create a cell with arrays A, B, C you write {A B C}
. So far so good.
Accessing array elements is done like this: arr(i)
. For Cells, it's cell{i}
. Still good.
Now let's try to delete an element. For arrays: arr(i) = []
. Extrapolating from examples above, you might try cell{i} = {}
for cells, but this is a syntax error. The correct syntax to delete an element of a cell is, in fact, the very same syntax you use for arrays: cell(i) = []
.
So, most of the time you access cells using special syntax, but when deleting items you use the array syntax.
If you dig deeper you'll find that actually a cell is an array where each value is of a certain type. So you can still write cell(i)
, you'll just get {A}
(a one-valued cell!) back. cell{i}
is a shorthand to retrieve A
directly.
All this is not very pretty IMO.