将矩阵转换为一行向量的最简单方法 [英] the easiest way to convert matrix to one row vector
本文介绍了将矩阵转换为一行向量的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何连接在MATLAB中将矩阵的行转换成向量?
Possible Duplicate:
How do you concatenate the rows of a matrix into a vector in MATLAB?
有人知道通过以下方式将原始矩阵的所有行(从1到M)放入新矩阵的第一行,从而从M x N矩阵创建一个行矩阵(向量)的最佳方法是什么:>
Does anyone know what is the best way to create one row matrix (vector) from M x N matrix by 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]
示例:
A = [1 1 0 0; 0 1 0 1]
B = [1 1 0 0 0 1 0 1]
有没有一种简单的方法或内置函数可以从A生成矩阵B?
Is there a simple method or perhaps a built-in function that could generate matrix B from A?
推荐答案
请尝试以下操作:B = A ( : )
,或尝试使用reshape
函数.
Try this: B = A ( : )
, or try the reshape
function.
http://www.mathworks.com/access/帮助台/帮助/techdoc/ref/reshape.html
这篇关于将矩阵转换为一行向量的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文