getting error by using princomp in matlab for writtinf code for PCA i.eAttempt to execute SCRIPT pca as a function: C:\Users\u​ser\Deskto​p\lib svm\pca.m Error in princomp (line 29) [varargout​{1:nargout​}]=pca(var​argin{1},'​Algorithm'​,'svd','Ec​onomy

here is my code
data=xlsread('cloln.xlsx');
B=data-repmat(mean(data),62,1);
[coff,score,latent]=princomp(B);
S=cumsum(latent)./sum(latent);
s=S';
display(size(coff));
for i=1:4
if(s(i)<0.99)
coff(:,i)=[];
end
end
display(size(coff));
score1=B*coff;

回答(1 个)

The PRINCOMP function calls PCA. Normally it calls the PCA function in Statistics and Machine Learning Toolbox but since you have created your own pca.m script file (C:\Users\user\Desktop\lib svm\pca.m) in the current directory or higher on the MATLAB search path than the toolbox, it tries to call that script file like a function instead. This will not work, and MATLAB throws an error when it tries to call that script like a function. I recommend renaming or removing your pca.m script file.

类别

帮助中心File Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by