MATLAB Answers

Duplicating element in table that is stored in cell array

1 view (last 30 days)
Elizabeth
Elizabeth on 27 Jan 2016
Answered: Elizabeth on 27 Jan 2016
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!

  0 Comments

Sign in to comment.

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.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.