Search code examples
arraysmatlabcell

Defining array of cells/strings


I have quite a big array of strings that's in the format ['name1';name2';...], where names don't have the same size.

I know I have to use cells in MATLAB, but I can't figure out how to use it in this case.

The best I came up with was this, but it doesn't work.

names = cell(1,n);
names(1:n) = ['name1';'name2';...;'namen'];

Solution

  • The cell array concatenation operator is {};

    names = {'name1';'name2';...;'namen'};