在MATLAB中对列矢量进行折叠以返回其原始方阵

时间:2016-02-24 07:13:10

标签: matlab matrix vector

为了便于某些操作,我必须将n x n矩阵转换为n ^ 2 x 1列向量。现在,操作已完成,如何从n ^ 2 x 1向量返回到n x n形式。

应该与此相反:concatenation

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以使用reshape()功能:

//M is your n^2 x 1 column vector, A is your nxn matrix that you want to recover   
A = reshape(M, [n n])

如果你的n x n矩阵是3x3,那么:

A = reshape(M, [3 3])

了解更多信息:http://www.mathworks.com/help/matlab/ref/reshape.html