MATLAB: How to use a vector for filling columns of table

table

Hi, in my program I am creating a table of a certain width. the table is filled row by row in a for loop. Sometimes an error occurs and I handle this one with the try, catch command and then I go to the next row with the for loop. Now I want that if an error occurs the table entries of this row are all zero in each column except the first two values. I tried something like this but I really can not figure out how to get it work (table width varies thats why I have to do it like this)
new_table = table({num2str(id)}, {'error'}, [zeros(1, width(new_table)-2)])
the answer should look like this then:
Var1 Var2 Var3 Var4 Var5 Var6 Var7
________ _______ ____ ____ ____ ____ ____
'466451' 'error' 0 0 0 0 0
thank you very much 🙂
Joe

Best Answer

cell2table([{num2str(457888)}, {'error'}, num2cell(zeros(1, size(new_table,2)-2))])