Search code examples
matlabmultidimensional-arraymachine-learningpca

Reason of Non-singleton dimensions mismatch in data under PCA


During pca analysis using built in pca function in matlab, I faced the following error. Data is actually a feature vector obtained from 30 MR images.

>> size(data)
  ans =
  30   281   389   104 

[coeff score varience] = pca(data);

Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.

Error in pca>localSVD (line 468)
x = bsxfun(@times, x, PhiSqrt);

Error in pca (line 341)
    [U,sigma, coeff, wasNaN] = localSVD(x, n,...

Would you let me know any solution?


Solution

  • The documentation says it expects its input as an input matrix of NxP. You probably need to reshape your matrix to match this input requirements.