how to store elements from 2 arrays into another array?
15 次查看(过去 30 天)
显示 更早的评论
ex: a=[1,2,3,4,5]; b=[6,7,8,9,10]; i want in a new array in 1st row as 1,6 2nd row 2,7 and so on. how do i do it in matlab?
0 个评论
采纳的回答
Star Strider
2018-4-4
Probably the easiest way:
a = [1,2,3,4,5];
b = [6,7,8,9,10];
c = [a(:) b(:)]
c =
1 6
2 7
3 8
4 9
5 10
The (:) subscript reference creates column vectors. These are then concatenated horizontally to create ‘c’.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!