creating a new column with three columns
显示 更早的评论
hello everyone,
i have three columns with 25 rows each. Now I want to merge all the three columns to one in a way that the first three rows will be the 1st values of all the three columns.
for ex: col_1, col_2 col_3 I need New merge col
25 22 23 25
26 25 20 22
24 28 30 23
26 and so on
so at last i will get one column with total of 75 rows
thanks in advance.
采纳的回答
更多回答(2 个)
Works also if the number of lines or columns is different to 25x3:
a = [col1 col2 col3]
b = reshape(a',[],1)
3 个评论
Prakhar Modi
2019-6-25
编辑:Prakhar Modi
2019-6-25
Stephan
2019-6-25
see my edited answer
Prakhar Modi
2019-6-25
编辑:Prakhar Modi
2019-6-25
Pullak Barik
2019-6-25
编辑:Pullak Barik
2019-6-25
I will proceed in the following way-
1) Merge col_1, col_2, col_3 into a single matrix.
2) Reshape the transpose of the array.
The following code does the same-
res = reshape([col_1 col_2 col_3].', [], 1)
2 个评论
Prakhar Modi
2019-6-25
Pullak Barik
2019-6-25
Are your col_1, col_2 and col_3 variables stored as column vectors or row vectors?
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!