Clear Filters
Clear Filters

How change two columns with 5 rows to a single row?

18 views (last 30 days)
x= [2 4 6 8 10 ];
y= [20 40 60 80 100];
% I want to reprsent them in a single row like that z= 2 20 4 40 . . .

Accepted Answer

David Goodmanson
David Goodmanson on 26 Jul 2024 at 8:29
Edited: David Goodmanson on 26 Jul 2024 at 8:37
Hi Bajdar,
xy = [x; y];
z = xy(:)'
i.e. concatenate x and y vertically, read that matrix out columnwise, then take the transpose. If x or y could be complex, then
z = xy(:).'
(transpose, not complex conjugate transpose) is necessary.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!