Tuesday, July 30, 2019

Matlab: Dynamic cell array with string elements

In Matlab, to dynamically update cell array with string elements, use the following:

myCellArray = {}; %initializing cell array
for i=...
    myCellArray = [myCellArray; someString]; %dyn. update cell array
end

Note that when initializing the cell array you use curly brackets "{ }", while resizing the cell array you use square brackets "[ ]".

No comments: