collapsing rows of a cell array into a single cell

8 次查看(过去 30 天)
I have a 312x3 cell called 'data'. In the first column there are 312 rows of different x-values, the second column there are 312 rows of different y-values, and in the third column there are 312 rows of t-values. I want to collapse all the rows of each column into a single cell, such that all the x-values are in a single cell (first column), all the y-values are in a single cell (second column), and all the t-values are in a single cell (third column). For instance, if I started with the following 6x4 cell array called Data:
Data =
0.935 4 24 0.07
0.759 5 74 0.01
0.681 2 21 0.09
0.823 1 16 0.06
0.894 3 7 0.01
0.953 5 67 0.03
I can't figure out how to transform this into the following 1x4 cell array (Data2)
Data2 =
([0.935 0.759 0.681 0.823 0.894 0.953] [4 5 2 1 3 5] [24 74 21 16 7 67] [0.07 0.01 0.09 0.06 0.01 0.03], :)
Is there a piece of code that can do this?
I hope this makes sense! Thanks for the help.
Best wishes,
Billy

采纳的回答

Matt J
Matt J 2023-1-31
编辑:Matt J 2023-1-31
Data2=num2cell(Data,1);
However, I wonder why you would want to do this. Matrices are usually faster to manipulate than cells, and you can do matrix math with them.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by