I would like to create a table of 5 columns and 10000 rows, such that it has headers with empty cells in the beginning. I will fill in the cells with strings or numbers later after calculation. How to do that? Thanks.
Jen
The only 'empty' table MATLAB can create, is 0x0. To check this, create a table T of non-zero dimestions: just give it a size and some variable names and types. It will be populated with zeroes for the numeric datatypes, and non-empty cells containing an empty double for cells.
If you want the table to be empty use the WHERE 1=0 or TOP (0) on both sides of the UNION ALL. If you want a copy of the table with data then just put the WHERE 1=0 or TOP (0) on one side.
Description. s = getHeader( obj ) returns the text used as the header when displaying obj . This method is called once for the entire object array.
Description. H = height( T ) returns the number of rows in the table, T . height(T) is equivalent to size(T,1) .
Here is a way:
Let's say you have the following headers:
headers = {'A' 'B' 'C' 'D' 'E'};
Then initialize the data (in your case 10 000 x 5, here 4 x 5) as an empty cell. Then convert to a table and edit the VariableNames
property to make it the headers:
data = cell(4,5);
T = cell2table(data);
T.Properties.VariableNames = headers
Output:
T =
A B C D E
__ __ __ __ __
[] [] [] [] []
[] [] [] [] []
[] [] [] [] []
[] [] [] [] []
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With