Programming and Data Types | ![]() ![]() |
Applying Functions and Operators
Use indexing to apply functions and operators to the contents of cells. For example, use content indexing to call a function with the contents of a single cell as an argument.
A{1,1} = [1 2; 3 4]; A{1,2} = randn(3,3); A{1,3} = 1:5; B = sum(A{1,1}) B = 4 6
To apply a function to several cells of a non-nested cell array, use a loop.
for i = 1:length(A) M{i} = sum(A{1,i}); end
![]() | Replacing Lists of Variables with Cell Arrays | Organizing Data in Cell Arrays | ![]() |