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

1 view (last 30 days)
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;

Answers (1)

Steven Lord
Steven Lord on 18 Dec 2015
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.

Community Treasure Hunt

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

Start Hunting!