How do I add an array to a table?

159 views (last 30 days)
Mariana on 15 Dec 2019
Commented: Adam Danz on 16 Dec 2019
I already tried the matlab function arratotable. The error that I have is that the array is not of the same dimension of the table. How can I fix this problem ?

Accepted Answer

Adam Danz
Adam Danz on 15 Dec 2019
Edited: Adam Danz on 16 Dec 2019
If you're adding a new column of data to an existing table, the column must have an equal number of elements as all other columns of data in the table. One way of achieving that is by padding the shorter column(s) with NaN values (or some other default value).
Often times it's easiest just to pad values to the end of a column using [x; NaN(sz)] but there are functions that may come in handy such as B = padarray(A,padsize,padval).
If you have any problems implementing this method, show us your code and we can help straighten it out.
Adam Danz
Adam Danz on 16 Dec 2019
"Do you know how to make the sum of a value from a table and another in a cell array?"
This isn't clear to me. Could you give an example?

Sign in to comment.

More Answers (0)


Find more on Tables in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by