Filter löschen
Filter löschen

グラフでの座標の最大​値、最小値を出すには​どうすればいいですか​?

33 Ansichten (letzte 30 Tage)
R
R am 15 Nov. 2022
Kommentiert: R am 15 Nov. 2022
biplotでグラフを出しました。
このグラフにおける成分1, 成分2の最大値, 最小値を出す方法をご教授ください。

Akzeptierte Antwort

Hernia Baby
Hernia Baby am 15 Nov. 2022
Bearbeitet: Hernia Baby am 15 Nov. 2022
まずデータを作ります
clear; clc; close all
u1=5*randn(1,10000);
u2=randn(1,10000);
x1=1/2^0.5*u1+1/2^0.5*u2;
x2=1/2^0.5*u1-1/2^0.5*u2;
X=[x1 ; x2]';
pcaを行います
[coef, score] = pca(X);
biplot(coef,'Scores',score);
---------
以降が本題です
ここで注意ですがベクトルの方向によって最大と最小が逆になります
このグラフでと書いていますので正規化して算出しています
Cp1_max_min = [max(score(:,1)),min(score(:,1))]./max(abs(score),[],'all')
Cp1_max_min = 1×2
1.0000 -0.8342
Cp2_max_min = [max(score(:,2)),min(score(:,2))]./max(abs(score),[],'all')
Cp2_max_min = 1×2
0.1822 -0.1752
最大値だけ図示してみましょうか
figure
hold on
biplot(coef,'Scores',score);
[~,idx] = max(score(:,1));
cp1max = score(idx,:);
[~,idx] = max(score(:,2));
cp2max = score(idx,:);
cpmax = [cp1max;cp2max];
scatter(cpmax(:,1)./max(abs(score),[],'all'),cpmax(:,2)./max(abs(score),[],'all'),'k')
  1 Kommentar
R
R am 15 Nov. 2022
ありがとうございます。
図示までしてくださってとても分かりやすかったです。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu グラフィックス オブジェクトのプロパティ finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!