1
1 * 262144 행렬을 512 * 512 행렬로 재구성했습니다. 이제 제 2 행렬에서 특정 요소가 필요하며 원래 행 행렬에 있던대로 해당 위치를 알고 싶습니다. 말하자면, 나는 모양이 바뀐 매트릭스에서 (256,4)에있는 요소가 필요합니다. 원래 행의 행렬에서이 요소의 위치를 어떻게 알 수 있습니까?Matlab에서 변형 된 후 원본 행렬 w.r.t를 찾습니다.
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
의견이나 제안이 있으십니까?
감사합니다. 원래 행렬은 벡터이기 때문에
"범위 밖의 첨자 오류"가 표시됩니다. 더 나은보기를 위해 전체 코드를 다시 게시합니다. –
원래 게시물의 수정 된 코드를 참조하십시오. 감사합니다. –
@KashifNawaz 당신의'sub2ind' 라인에, 당신은 크기가 바뀌 었다고 생각합니다. 내 대답 –