I'm trying to insert a string into a specific cell in a table. I've tried a handful of combinations, including curly brackets, cellstr()… but can't seem to get the right combination. Stand-along code is below; thanks for any help, I am sure it is something simple that I am missing.
files = {'file1.txt', 'file2.txt', 'file3.txt'};mytable = NaN(length(files), 4);mytable = array2table(mytable);mytable.Properties.VariableNames = {'FILENAME', 'valueA', 'valueB', 'valueC'};for i = 1:length(files) filename = char(files(i)); % do things
mytable.FILENAME{i} = filename; % also save other values; these are all doubles, so they write to table easily
end
Here is the error message:
Unable to perform assignment because brace indexing is not supported for variables ofthis type.
Here are some other combos I have tried:
mytable.FILENAME{i} = cellstr(filename);Unable to perform assignment because brace indexing is not supported for variables ofthis type.
mytable.FILENAME{i} = filename;Unable to perform assignment because brace indexing is not supported for variables ofthis type.
mytable.FILENAME(i,:) = filename;Unable to perform assignment because the size of the left side is 1-by-1 and the sizeof the right side is 1-by-9.
mytable.FILENAME(i,:) = cellstr(filename);Conversion to double from cell is not possible.
Best Answer