Problem with direct calculation on table with std and "omitnan"

12 views (last 30 days)
Since R2023a, it is possible to perform calculations directly on tables (and timetables) without extracting their data by indexing.
I want use std directly on a numeric table where I can have nan.
For example :
load patients
T = table(Age,Height,Weight,Systolic,Diastolic)
mean(T,"omitnan")
It's fine.
But why there is a problem with std(T,"omitnan") ?
% Applying the function 'std' to the variable 'Age' generated an error.
I can use std(T{:,:},"omitnan") or std(T.Variables,"omitnan") but I lost the possibility to work directly with my table.
Did I miss something ?
Do you have any suggestion ?
Thank you in advance.
SAINTHILLIER Jean Marie

Accepted Answer

Star Strider
Star Strider on 17 May 2023
Prehaps varfun?
Example —
load patients
T = table(Age,Height,Weight,Systolic,Diastolic)
T = 100×5 table
Age Height Weight Systolic Diastolic ___ ______ ______ ________ _________ 38 71 176 124 93 43 69 163 109 77 38 64 131 125 83 40 67 133 117 75 49 64 119 122 80 46 68 142 121 70 33 64 142 130 88 40 68 180 115 82 28 68 183 115 78 31 66 132 118 86 45 68 128 114 77 42 66 137 115 68 25 71 174 127 74 39 72 202 130 95 36 65 129 114 79 48 71 181 130 92
S = varfun(@(x)std(x,'omitnan'),T)
S = 1×5 table
Fun_Age Fun_Height Fun_Weight Fun_Systolic Fun_Diastolic _______ __________ __________ ____________ _____________ 7.2154 2.8365 26.571 6.7128 6.9325
.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!