標準偏差(std)の重みについて

13 visualizzazioni (ultimi 30 giorni)
朋貴 熊田
朋貴 熊田 il 15 Mag 2022
Commentato: 朋貴 熊田 il 16 Mag 2022
stdを使用する際に値が0である行列を数えないで正規化したいのですが、何か良い方法はありますか?
ご教授お願いいたします。
  2 Commenti
Hernia Baby
Hernia Baby il 15 Mag 2022
0を除外するという認識でよろしいですか?
朋貴 熊田
朋貴 熊田 il 15 Mag 2022
はいその認識で間違えないです

Accedi per commentare.

Risposta accettata

Hernia Baby
Hernia Baby il 16 Mag 2022
std のオプションにNaNを除外する機能がありますので、0をNaNにしましょう
まずはデータを用意します
A = randi([-5 5],9)
A = 9×9
1 4 -4 -3 5 3 2 0 -2 3 -5 3 4 -5 1 4 -5 1 -1 -3 -3 3 -4 -1 1 -1 2 0 -3 2 5 0 -1 3 5 2 -5 1 -3 2 -4 1 -3 2 -2 3 -2 0 3 4 -2 4 -1 1 2 -1 -3 -1 4 4 2 1 -1 -5 4 5 -1 -1 -5 -1 1 -3 4 -2 3 0 -2 -5 -3 -5 0
0をNaNにします
A(A==0) = nan()
A = 9×9
1 4 -4 -3 5 3 2 NaN -2 3 -5 3 4 -5 1 4 -5 1 -1 -3 -3 3 -4 -1 1 -1 2 NaN -3 2 5 NaN -1 3 5 2 -5 1 -3 2 -4 1 -3 2 -2 3 -2 NaN 3 4 -2 4 -1 1 2 -1 -3 -1 4 4 2 1 -1 -5 4 5 -1 -1 -5 -1 1 -3 4 -2 3 NaN -2 -5 -3 -5 NaN
NaNを除外して計算します
std(A,'omitnan')
ans = 1×9
3.5757 3.1535 3.5857 2.8284 4.1036 3.1667 2.7386 3.4200 1.9821
  1 Commento
朋貴 熊田
朋貴 熊田 il 16 Mag 2022
ご回答ありがとうございます。

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su フィルター バンク in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!