How to calculate mean and standard deviation for loops?

7 ビュー (過去 30 日間)
Sumit Saha
Sumit Saha 2021 年 7 月 11 日
コメント済み: Sumit Saha 2021 年 7 月 11 日
story_Acc_FN_UL0_S1_5 = randn(1,10);
story_Acc_FN_UL0_S2_5 = randn(1,10);
story_Acc_FN_UL0_S3_5 = randn(1,10);
story_Acc_FN_UL0_S4_5 = randn(1,10);
story_Acc_FN_UL0_S5_5 = randn(1,10);
for uu = 1:10
story_Acc_FN_UL0_R_rup_5(1,uu) = mean(story_Acc_FN_UL0_S1_5(1,uu),story_Acc_FN_UL0_S2_5(1,uu),story_Acc_FN_UL0_S3_5(1,uu),story_Acc_FN_UL0_S4_5(1,uu),story_Acc_FN_UL0_S5_5(1,uu));
std_dvt(1,uu) = std(story_Acc_FN_UL0_S1_5(1,uu),story_Acc_FN_UL0_S2_5(1,uu),story_Acc_FN_UL0_S3_5(1,uu),story_Acc_FN_UL0_S4_5(1,uu),story_Acc_FN_UL0_S5_5(1,uu));
end

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2021 年 7 月 11 日
You don't need to use loop for that. You can use cat command to concatenate, and then use mean and std functions to the matrix itself.
story_Acc_FN_UL0_S1_5 = randn(1,10);
story_Acc_FN_UL0_S2_5 = randn(1,10);
story_Acc_FN_UL0_S3_5 = randn(1,10);
story_Acc_FN_UL0_S4_5 = randn(1,10);
story_Acc_FN_UL0_S5_5 = randn(1,10);
matrix=cat(1,story_Acc_FN_UL0_S1_5,story_Acc_FN_UL0_S2_5, story_Acc_FN_UL0_S3_5, story_Acc_FN_UL0_S4_5, story_Acc_FN_UL0_S5_5)
matrix = 5×10
0.5803 0.2545 1.3201 1.1169 1.1713 0.6641 0.6268 0.1792 0.5207 -0.8742 0.2123 -1.1177 -0.7340 -0.4116 1.6859 0.4254 -0.0838 -1.3029 0.2514 -0.0004 -0.1874 -1.3762 0.4546 -1.2224 0.4418 1.2452 0.7849 2.4942 -0.3359 -0.7775 -0.5222 2.1919 -0.1692 0.7816 0.0996 0.9557 -0.5402 0.5236 0.8086 -0.5950 1.0547 0.4665 -0.0449 0.7405 -0.2555 -1.1399 0.4181 -0.7332 -2.2922 1.3358
meanvalue=mean(matrix)
meanvalue = 1×10
0.2276 0.0838 0.1653 0.2010 0.6287 0.4301 0.2412 0.2322 -0.2095 -0.1823
stdev=std(matrix)
stdev = 1×10
0.6211 1.4313 0.7717 0.9834 0.7920 0.9301 0.5458 1.4571 1.2385 0.9139

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by