Duplicating element in table that is stored in cell array

2 views (last 30 days)
Hello,
I have a cell array like this:
d = [1x4 table] [2x4 table] [4x15 table]
I collected the result in the cell array because they have different size, as you can see. However, I need to make them having the same number of row, so I need to duplicate it based on the highest number of row (in this case: 4). So if I have (in table)
B = 2 2 2 2 ; 5 5 5 5
the duplication that I need to have is (in table)
B = 2 2 2 2 ; 2 2 2 2 ; 5 5 5 5; 5 5 5 5
I need to store the result in table because the number exceeds the bit provided by Matlab if I store them in matrix, so it will generate 32767 instead of the correct result.
What I tried to use is kron function. However, it does not work with table.
Can anyone help me with it? I am using matlab r2014b. Thanks a lot!

Accepted Answer

Elizabeth
Elizabeth on 27 Jan 2016
I found it. In case people need, I put the algorithm here.
So, what I did are:
1. I check the size difference and identify the duplication should be done.
2. Create a new matrix and convert that into table.
3. Fill the table with the data I need.
I realized that because I work with table, I need to create an empty table.

More Answers (0)

Categories

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!