Mean of selected range of a matrix based on a range of values from another matrix

Hello everyone,
I have a mat file (attached) containing 4 parameters: month, sa, ta, and sig. My intention is to get the mean and standard deviation from each month of sa and ta at a specific range of sig (let's say the value of sig : 27.4 - 27.5).
So, the intended output should be like this:
Thank you!

2 件のコメント

Shivam Gothi
Shivam Gothi 2024 年 10 月 10 日
What I understand is, you want to find the mean and the standard deviation of only those set of values of "ta" and "sa" for which "sig" is within the range of 27.4 - 27.5. Also, the "sig_range" is different for different months.
Is my understanding of question corrrect ?
Adi Purwandana
Adi Purwandana 2024 年 10 月 10 日

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

 採用された回答

Voss
Voss 2024 年 10 月 10 日
load('data_my.mat')
T = table(month,sa,ta,sig);
% only sig 27.4 to 27.5
idx = sig >= 27.4 & sig < 27.5;
G = groupsummary(T(idx,:),'month',{'mean','std'},{'sa','ta'})
G = 3x6 table
month GroupCount mean_sa std_sa mean_ta std_ta _____ __________ _______ _________ _______ _______ 10 3360 34.611 0.0047013 3.4963 0.27562 11 4320 34.608 0.0063067 3.4344 0.33247 12 792 34.61 0.0081189 3.3022 0.38516
% for reference, all sig
G = groupsummary(T,'month',{'mean','std'},{'sa','ta'})
G = 12x6 table
month GroupCount mean_sa std_sa mean_ta std_ta _____ __________ _______ _________ _______ _______ 1 4464 34.609 0.0081535 3.2774 0.35106 2 4032 34.608 0.006585 3.4279 0.3524 3 4464 34.609 0.0056887 3.4532 0.31757 4 4320 34.611 0.0049732 3.5148 0.32073 5 4464 34.612 0.005491 3.4808 0.33566 6 4320 34.61 0.0058029 3.4186 0.33016 7 4464 34.61 0.006245 3.444 0.35342 8 4464 34.609 0.0065816 3.4272 0.35374 9 2203 34.612 0.0081435 3.2829 0.44816 10 3361 34.611 0.004702 3.4963 0.27559 11 4320 34.608 0.0063067 3.4344 0.33247 12 4464 34.609 0.007599 3.3792 0.36885

4 件のコメント

Adi Purwandana
Adi Purwandana 2024 年 10 月 10 日
編集済み: Adi Purwandana 2024 年 10 月 10 日
Perfect! Thank you, my additional following question if you don't mind, could you please present the boxchart/boxplot for each month of that specified range of sig (sig >= 27.4 & sig < 27.5)?
load('data_my.mat')
T = table(month,sa,ta,sig);
% only sig 27.4 to 27.5
idx = sig >= 27.4 & sig < 27.5;
boxchart(T{idx,'month'},T{idx,'sa'})
boxchart(T{idx,'month'},T{idx,'ta'})
Adi Purwandana
Adi Purwandana 2024 年 10 月 11 日
Great, thank you @Voss!
Voss
Voss 2024 年 10 月 11 日
編集済み: Voss 2024 年 10 月 11 日
You're welcome! Any questions, let me know.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2024 年 10 月 10 日

編集済み:

2024 年 10 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by