concatenate a cell array(string) and a double array numeric
18 次查看(过去 30 天)
显示 更早的评论
i have 2 arrays:
x = {'tom' 'sara' 'bob'} y = [ 1 2 3 ; 3 4 5 ; 1 4 2]
how can i concatenate x and y vertically with a single array with x as header?
1 个评论
Jan
2012-3-28
This topic has been discussed already: http://www.mathworks.com/matlabcentral/answers/33087-how-to-combine-an-cell-array-and-a-double-array
Please do not double-post.
回答(1 个)
Andrei Bobrov
2012-3-28
out = [x;num2cell(y)];
2 个评论
Jan
2012-3-28
The quote characters are not part of the array, but inserted when printing to the command window only. They show, that the included characters are a string, e.g. to distinguish '9' from 9.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!