Using the C Math Library    

Assigning Values to a Cell Array  

You put a value into a cell array in much the same way that you read a value out of a cell array. In MATLAB, the only difference between the two operations is the position of the cell array relative to the assignment operator: left of the equal sign (=) means assignment, right of the operator means reference. No matter if you're reading or writing values, the indexing operations you use to specify which values to access remain the same.

This is true in the MATLAB C Math Library as well. The only difference between reading values from a cell array and writing values to a cell array is the function you call. mlfIndexRef() reads values; mlfIndexAssign() writes values.

For example, each of the mlfIndexRef() examples presented in the previous sections will also work with mlfIndexAssign() if you provide a source array of the correct size as the last argument to mlfIndexAssign().

Like mlfIndexRef(), mlfIndexAssign() distinguishes between cell array indexing and standard indexing. For example, to assign a vector [1 2 5 7 11] to the contents of the cell (1,2) of A, you write A{1,2} = [1 2 5 7 11] in MATLAB and

in C with the MATLAB C Math Library. Assume the array variable vector is set to the vector of primes above.

You could have written the previous assignment in MATLAB as
A(1,2) = { [1 2 5 7 11] }. The corresponding MATLAB C Math Library code is:

Because this assignment uses parentheses instead of braces, it is an assignment between cells, which means the source array (on the right-hand side of the assignment operator) must be a cell array as well. The first line of C code creates a cell array from our initial vector of primes.


 Indexing Nested Cell Arrays Deleting Elements from a Cell Array