Calculate Standard deviation in table

47 ビュー (過去 30 日間)
Dion Theunissen
Dion Theunissen 2021 年 6 月 25 日
コメント済み: Dion Theunissen 2021 年 6 月 25 日
Hi,
I have a table with 20 columns, I want to make a new column with the standard deviation of each row from column 4 to 6.
So after column 6 i want to have a column with the stdev of all rows of column 4:6.
How can I do that?

採用された回答

Chunru
Chunru 2021 年 6 月 25 日
a = array2table(rand(5,8)) % Sample table
a = 5×8 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 _______ _______ _______ _________ _______ _________ _______ _______ 0.4022 0.9627 0.53548 0.35205 0.70636 0.89738 0.50393 0.44203 0.96785 0.33289 0.57833 0.36493 0.84985 0.0031283 0.34461 0.3312 0.29543 0.18861 0.91065 0.025623 0.40162 0.88419 0.24007 0.38235 0.66403 0.19131 0.24685 0.0092594 0.10672 0.51052 0.79236 0.43115 0.62483 0.95579 0.37075 0.11087 0.65024 0.55079 0.97985 0.57458
s = std(a{:, 4:6}, [], 2) % std along rows (dim=2)
s = 5×1
0.2767 0.4249 0.4304 0.2658 0.2870
b = [a table(s, 'VariableNames', {'std'})] % combine with original
b = 5×9 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 std _______ _______ _______ _________ _______ _________ _______ _______ _______ 0.4022 0.9627 0.53548 0.35205 0.70636 0.89738 0.50393 0.44203 0.27671 0.96785 0.33289 0.57833 0.36493 0.84985 0.0031283 0.34461 0.3312 0.42485 0.29543 0.18861 0.91065 0.025623 0.40162 0.88419 0.24007 0.38235 0.43038 0.66403 0.19131 0.24685 0.0092594 0.10672 0.51052 0.79236 0.43115 0.26577 0.62483 0.95579 0.37075 0.11087 0.65024 0.55079 0.97985 0.57458 0.28704
  1 件のコメント
Dion Theunissen
Dion Theunissen 2021 年 6 月 25 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by