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
Voss
Voss 2024년 10월 11일
편집: Voss 2024년 10월 11일
You're welcome! Any questions, let me know.

댓글을 달려면 로그인하십시오.

추가 답변 (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