How to create a two columns cell array from two different cells?

Hi all,
I've got two 781x1 cells.
for k=1:1:781
Time3{k}=(k);
Ratt1{k}=(Ratt);
end
The second one contains 781 vectors of different lengths made of different combinations of numbers from 1 to 24.
The vectors Ratt are generated by a function.
I'd like to join them into a 781x2 cell array so I could read numbers from 1 to 781 in the first column and all the vectors in the second one, like this:
1 [1, 2, 5, 7, 8]
2 [3, 11, 15]
.........
Is it possible?
Thanks

 采纳的回答

k = 1 : numel(vectors);
Wanted = [num2cell(k(:)), num2cell(vectors(:), 2)]

3 个评论

Sorry madhan, I've triied to do what you've suggested but in gives me back the first column with all numbers from 1 to 781 (that's ok) but in the second one I see the number of elements of each vectors, not the vectors.
I've edited my question to be more clear. Thank you.
[Time3, Ratt1] = deal(cell(781,1));
for k=1:781
Time3{k} = k;
Ratt1{k} = Ratt;
end
Wanted = [Time3, Ratt1]
Now it works perfectly!!! Thank you madhan ravi!!!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by