Mean and Standard deviation table

17 visualizaciones (últimos 30 días)
Cheuk Yin Wong
Cheuk Yin Wong el 20 de Ag. de 2022
Editada: the cyclist el 20 de Ag. de 2022
I have a table "cal_table" and it looks like this:
I would like to find the mean and standard deviation of each 'cal0_05mM', 'cal0_03mM', ..., 'cal0_50mM' by teh three 'Rep'. What is the quickest way to do it?
Thank you very muuch.

Respuesta aceptada

Image Analyst
Image Analyst el 20 de Ag. de 2022
Editada: Image Analyst el 20 de Ag. de 2022
m = reshape(cal_table.Var2, 3, []); % Get 3-by-5 matrix.
means = mean(m, 1) % Get means of each column
sds = std(m, 1) % Get standard deviations

Más respuestas (1)

the cyclist
the cyclist el 20 de Ag. de 2022
You can use the groupsummary command.
  1 comentario
the cyclist
the cyclist el 20 de Ag. de 2022
Editada: the cyclist el 20 de Ag. de 2022
To be more specific, you can do the one-liner
groupsummary(cal_table,Var1,["mean","std"])
Here is an example, related to the one in the documentation:
% Some data
Gender = ["male";"female";"female";"male";"male"];
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Gender,Age,Height,Weight)
T = 5×4 table
Gender Age Height Weight ________ ___ ______ ______ "male" 38 71 176 "female" 43 69 163 "female" 38 64 131 "male" 40 67 133 "male" 49 64 119
% Get the mean and std
groupsummary(T,"Gender",["mean","std"])
ans = 2×8 table
Gender GroupCount mean_Age std_Age mean_Height std_Height mean_Weight std_Weight ________ __________ ________ _______ ___________ __________ ___________ __________ "female" 2 40.5 3.5355 66.5 3.5355 147 22.627 "male" 3 42.333 5.8595 67.333 3.5119 142.67 29.704

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by