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

8 visualizaciones (últimos 30 días)
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 comentarios
Shivam Gothi
Shivam Gothi el 10 de Oct. de 2024
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 ?

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 10 de Oct. de 2024
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 comentarios
Voss
Voss el 11 de Oct. de 2024
Editada: Voss el 11 de Oct. de 2024
You're welcome! Any questions, let me know.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by