matlab에서 정사각형 행렬을 희소하게 표현했습니다. 행렬과 열의 시간을 제거하여 고유 값과 고유 벡터를 n-1 번 계산 한 고유 분석을 수행하려고합니다. 내 문제는 행 및 열 제거를 수행하는 방법입니다. 내 코드 :희소 행렬 표현에서 열과 행을 동적으로 제거
A = textread('matrices.txt'); %nx3 matrix
for k=1:n% size of the matrix
display(k)
temp = A;
for index_i =1:length(temp)
if(temp(index_i, 1)== k | temp(index_i,2) == k)
temp(index_i,:) = [];
end
end
S = spconvert(temp); % sparse representation of the matrix
[a b] = eigs(S); % calculate the first six eigenvalues and eigenvectors
temp_vectors(:,k) = a(:,1);
temp_values(k) = b(1,1);
end
색인에 문제가 생겼습니다 (index_i, :) = []; 기본적으로 당신은 그러나 구현이 더 낫다, 내가 다른 짓을 맞다 :
또한
for k=1:10000 % size of the matrix
temp = A;
counter = 1;
list = [];
display(k)
for index_i =1:length(temp)
if(temp(index_i, 1)== k | temp(index_i,2) == k)
list(counter) = index_i;
counter = counter + 1;
end
end
temp(list(:),:)= [];
size(temp)
S = spconvert(temp); % sparse representation of the matrix
[a b] = eigs(S); % calculate the first six eigenvalues and eigenvectors
%temp_vectors(:,k) = a(:,1);
temp_values(k) = b(1,1);
name = strcat('eigen_vectors\eigen_vector_', int2str(k) ,'.mat');
vec = a(:,1);
save(name, 'vec');
끝, 새로운 문제가 발생합니다. 문제는 n 차 고유 분석의 계산에있다. 10. 행렬을 고유하게 분석하기 위해 10.000 번째 행과 열을 제거해야합니다. 그러나 그렇게함으로써 10000 번째 행/열을 삭제하기 때문에 9999 크기의 고유 벡터를 계산합니다. 이 문제를 극복하기위한 아이디어가 있습니까?