2 views (last 30 days)

Show older comments

%from struct to matrix using function

T1 = createDataMatrix(REC);

x=ismissing(T1);

y=any(x,1);

z=T1(:,~y);

a=z;

% scaling data for each column using standardised Z

ZM=zscore(a);

ZM=ZM-mean(ZM);

%PCA using Matlab built-in function

[coeff,score,latent,~,explained,~]=pca(ZM);

Ive J
on 31 Aug 2021

Well you should find the answer in your problem not MATLAB pca function. You have 45 observations with 484 variables, so degree of freedom (you already centered your variables) in your case would be 44 and that's the max number of PCs with a non zero variance. You need to look at the total variance explained and pick those PCs explaining much of the variance (let's say 90%); I highly doubt the number of PCs explaining that much of variance even exceeds half of variables in a real case situation (though I admit depends on the nature of the problem).

Bottom line: pca function works just fine.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!