MATLAB-矢量到矩阵的转换

MATLAB-矢量到矩阵的转换,matlab,Matlab,如何将MATLAB中的向量转换为这种特定类型的矩阵?列数将是一个参数 您可以(一次性)使用索引(第一列为1:L,第一行为1:K等)构建一个矩阵,然后根据这些索引从数据向量中进行选择 % matrix containing the indices indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix % now get the data from the vector, based on the indices X=x(ind

如何将MATLAB中的向量转换为这种特定类型的矩阵?列数将是一个参数

您可以(一次性)使用索引(第一列为1:L,第一行为1:K等)构建一个矩阵,然后根据这些索引从数据向量中进行选择

% matrix containing the indices 
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);

你想重塑向量的形状吗<编码>重塑然后再进行。考虑阅读文档/使用一个搜索引擎之前,在这样问,基本的“教程”-类似的问题是脱颖而出不只是一个重塑,因为一些价值被复制。