【发布时间】:2014-05-23 13:39:23
【问题描述】:
我有一个 1*262144 矩阵,我已将其重新整形为 512*512 矩阵。现在,我需要第二个矩阵中的某些元素,并且想知道它们在原始行矩阵中的位置。说,我需要在我的重塑矩阵中位于 (256,4) 的元素。我怎样才能知道这个元素在我原来的仅行矩阵中的位置?
matri_working_now = C(1,:);
matrix_working_now = reshape(matri_working_now,512,512);
[nrows,ncols] = size(matrix_stables); %matrix_stables is a matrix over which I am looping over which contains the locations of the desired elements as per the reshaped matrix. this itself is a 30839*2 matrix
for row = 1:nrows
for col = 1:ncols
%sub2ind(size(matrix_working_now),row,col)
%fprintf('iteration is equal to %6.2f.\n',row,col);
[rowss colum] = ind2sub(size(matri_working_now),sub2ind(size(matrix_working_now),matrix_stable(row),matrix_stable(col))); % i am accessing the elements of matrix_stables which provide me the row and column numbers;
end
end
有什么建议/想法吗?
谢谢!
【问题讨论】:
标签: arrays matlab matrix reshape