Hi, I have used array2table to create a two column blank table (the table has only header when it created). And the specific contents for each cell at each row are filled in by loop. The problem is, after I give the first value to the first cell (it is a string), then the first row created and the second cell in the same row is defined as non-cell (i.e. default is 0, which is a double). So when I tried to give the second cell a string, the program stops me doing so as it states "Cell contents assignment to a non-cell array object". But I did the same thing before with so many .m file, it never happen to me. Funny thing is, i checked with an old workable file and it cannot be execute as well with the same error. Could anyone kindly help me with this please? Many thanks. The code is simplified as follow:
network=readtable('New Microsoft Excel Worksheet.xlsx');network.Properties.VariableNames{1}='Region';network.Properties.VariableNames{2}='Depot';network.Properties.VariableNames{3}='Customer';route=array2table(zeros(0,2));route.Properties.VariableNames{1}='From';route.Properties.VariableNames{2}='To';k=1;for i=1:1:size(unique(network.Depot),1) for j=1:1:size(unique(network.Depot),1) if strcmp(network.Depot{i},network.Depot{j})==0 route.From{k,1}=network.Depot{i}; route.To{k,1}=network.Depot{j}; k=k+1; end endend
Best Answer