how to convert 2D matrix to 1D
984 views (last 30 days)
Show older comments
i want to convert 2D array with size 83*6580 to 1D array , any help ?
0 Comments
Answers (2)
Star Strider
on 13 Dec 2014
If you just want to make a vector out of it, use the ‘(:)’ notation:
A = rand(83,6580);
V = A(:);
‘V’ is a (546140x1) double.
3 Comments
AIJAZ BHAT
on 2 Nov 2020
Edited: AIJAZ BHAT
on 2 Nov 2020
Alright I also want to add a precaution here while using it, It operates in column wise concatenation.
अंबरीश प्रशांत चांदूरकर Ambarish Prashant Chandurkar
on 26 Jul 2019
To Convert a 2D Matrix into a 1D Array( i.e a row vector), such that row vector is formed by concatenating consecutive rows of the 2D Matrix, use the following Code :
OneDArray = reshape(TwoDArray',[1 size(TwoDArray,1)*size(TwoDArray,2)]);
2 Comments
See Also
Categories
Find more on Multidimensional Arrays 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!