필터 지우기
필터 지우기

How can I plot direction of principal components in PCA

조회 수: 17 (최근 30일)
farshad jahangiri
farshad jahangiri 2022년 9월 27일
댓글: farshad jahangiri 2022년 9월 27일
Hi I want to plot principal component's direction like this picture in 2D space. How can I do it ?

채택된 답변

Chunru
Chunru 2022년 9월 27일
x = randn(4, 2);
plot(x(:,1), x(:,2), 'ro', 'DisplayName', 'data'); axis equal; hold on
p = pca(x);
xc = mean(x);
quiver(xc(1), xc(2), p(1, 1), p(2, 1), 'b' , 'DisplayName', 'Principal');
quiver(xc(1), xc(2), -p(1, 1), -p(2, 1), 'b','HandleVisibility','off');
quiver(xc(1), xc(2), p(1, 2), p(2, 2), 'g', 'DisplayName', 'secondary');
quiver(xc(1), xc(2), -p(1, 2), -p(2, 2), 'g','HandleVisibility','off');
legend

추가 답변 (0개)

카테고리

Help CenterFile 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