How do I convert a cell array with multiple values per cell into a numerical array with multiple rows?
Show older comments
Hi,
I have a cell array called split_newdata_mean which contains multiple cells. Each of these cells contains five values in five rows.
I am looking to create a new numerical array in which the first column contains all the values from the first row of each cell in split_newdata_mean, the second column contains all the values from the second row of the of each cell and so on.
In the end I would have a array with five columns and as many rows as there are cells in split_newdata_mean.
How would that look?
Thank you!
Accepted Answer
More Answers (1)
n = 13;
C = cell(1,n);
for i=1:n
C{i} = rand(5,1);
end
A = cell2mat(C)
class(A)
4 Comments
lil brain
on 11 Dec 2022
C is split_newdata_mean.
So you should only need the command
A = cell2mat(split_newdata_mean)
if your explanation about split_newdata_mean is correct (cell array of size (1,n) with each element containing a column vector with 5 elements).
Categories
Find more on Operators and Elementary Operations 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!