how to append "specific columns" in an array
4 次查看(过去 30 天)
显示 更早的评论
hello ,
i tried so many combinations of codes using reshape and permute function but i couldn't get the desired output
suppose my array looks like
0 0
0 0
1 1
0 1
there are 2 columns and i want to take 1st column and copy it in 2nd and 3rd column , but i want to append it , i dont want to overwrite existing columns
so as a result i want 6 columns
0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1
0 0 0 1 1 1
i tried 2 clear my problem .... Can AnyOne Help With This Please??
I am Looking for Generalized code that can work for every array
2 个评论
采纳的回答
Mischa Kim
2014-3-20
编辑:Mischa Kim
2014-3-20
Pooja, use
B = reshape(repmat(A,3,1),length(A(:,1)),[])
assuming the first column is (supposed to be, typo?) equal to the second one in the 12-column matrix.
4 个评论
Mischa Kim
2014-3-20
See above. What else do you need to generalize? The number of repeated columns?
更多回答(1 个)
Chandrasekhar
2014-3-20
A = [0 0 0 0;0 0 1 0;1 1 1 1;0 1 0 1];
appending 1st column of A at the end|
A = [A A(:,1)];
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!