- If each row or column of your input matrix represents an independent measurement, remove all rows (or columns) that contain any NaN values.
- Set all NaN values to zero, or to the mean (or median) of all values in the matrix. Possibly, it would be better to set them to the mean of the row or column that they are in, if these each represent one type of measurement.
- Take a look at the fillmissing function, perhaps one of the options there would be suitable for replacing the NaN values in your input data.
Error in computing pca with nan values
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello,
I used pca. After computing the covariance matrix, I saw the NaN values in it. When I want to calculate the eigenvalues and eigenvectores, it gives an error.
Error using eig
Input matrix contains NaN or Inf.
Error in TrainData (line 113)
[V,LAMBDA]=eig(C);
Please guide me
thank you
댓글 수: 1
Christine Tobler
2019년 10월 28일
PCA is based on SVD or EIG, and these functions do not support NaN inputs. This is because there is no simple, unique way to ignore NaN values when computing these function.
Some ideas:
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!