你的问题是一个非常具体的问题。我不明白这对除了你自己以外的人有什么用处。 没有“单线解决方案”。 有很多方法可以解决索引问题,我喜欢用标索引时可能:
Ncolumns = size(Matrix,1);
Nblocks = floor(Ncolumns/4); %number of 4-line blocks (excluding the last block if it is not a full 4-lines)
IndexVector = (1:3)'*ones(1,3) + ones(3,1)*(0:2) * Ncolumns; %this gives 3 lines as specified.
IndexVector = [IndexVector(:); 4]; %this adds the first element of 4th line, as spec.
IndexVector = IndexVector*ones(1,Nblocks)+ones(10,1)*(0:Nblocks-1)*4; %this repeats the above for rest of blocks.
IndexVector = IndexVector(:)'; %make row vector
vector=Matrix(IndexVector);
if mod(Ncolumns,4) %this deals with the last partial block
subMat=Matrix(Nblocks*4+1:end,1:3);
vector=[vector subMat(:)'];
end
你觉得重塑时,与一个for循环?无论如何,你应该展示你迄今为止的尝试。这样做我和你将有更好的机会在这里获得帮助。 – patrik
你的描述说你以某种方式重新排列元素,但矩阵和向量包含不同的元素。 – Daniel
我尝试重塑矩阵,但它不起作用。 – Dani