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

8 次查看(过去 30 天)
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 ?

请先登录,再进行评论。

采纳的回答

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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by