开发者

the easiest way to convert matrix to one row vector [duplicate]

开发者 https://www.devze.com 2022-12-28 17:21 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: How do you concatenate the rows of a matrix into a vector in MATLAB?
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

How do you concatenate the rows of a matrix into a vector in MATLAB?

Hi,

Does anyone know what is the best way to create one row matrix (vector) from M x N matrix b开发者_开发知识库y putting all rows, from 1 to M, of the original matrix into first row of new matrix the following way:

A = [row1; row2; ...; rowM]
B = [row1, row2, ..., rowM]

Example:

A = [1 1 0 0; 0 1 0 1]
B = [1 1 0 0 0 1 0 1]

Is there a simple method or perhaps a built-in function that could generate matrix B from A?


Try this: B = A ( : ), or try the reshape function.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/reshape.html


You can use the function RESHAPE:

B = reshape(A.',1,[]);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号