pca function returns the wrong output in R2022a

Dear all,
I tried to use pca on 10x16 matrix. The function returned a 16x1 vector for coeff. According to the documentation it should be 16x16 matrix in my case. I figured, there must be something wrong with my input matrix, so I tried the example from the pca documentation page and got this:
load hald
>> coeff=pca(ingredients)
coeff =
517.7969
67.4964
12.4054
0.2372
Can there be something wrong with the pca function? Maybe its version issue. I am using R2022a.
Does anyone experience something similiar?

 채택된 답변

Let's check that you're using the pca function included in Statistics and Machine Learning Toolbox. What does this command show?
which -all pca
/MATLAB/toolbox/stats/stats/pca.m /MATLAB/toolbox/stats/bigdata/@tall/pca.m % tall method /MATLAB/toolbox/stats/gpu/@gpuArray/pca.m % gpuArray method

댓글 수: 6

This is what I get:
>> which -all pca
C:\Users\Paul\Documents\MATLAB\FlyLFM-Paul\Matlab\fieldtrip-master\external\dmlt\external\murphy\KPMstats\pca.m
C:\Program Files\MATLAB\R2022a\toolbox\stats\stats\pca.m % Shadowed
C:\Program Files\MATLAB\R2022a\toolbox\stats\bigdata\@tall\pca.m % tall method
C:\Program Files\MATLAB\R2022a\toolbox\stats\gpu\@gpuArray\pca.m % gpuArray method
I think the problem is that there is another function called pca.m in a different folder. Should I delete it or can I simply remove it from the path?
@Paul - Is it a function you wrote yourself? Look at the code. Where did it come from? Did it come from MathWorks? If so, then be careful about deleting supplied code. However, if it is doing something strange, then it is very likely something you wrote yourself, in which case it should be deleted, or at least renamed.
Searching for "KPMstats" it looks like this came from a deprecated suite of software "by Kevin Murphy and students".
I didn't write it myself. It came with a repository that was left behind by a former colleague.
I excluded the folder from my path. Now pca works as expected. Thanks for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2023년 6월 6일

댓글:

2023년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by