Field of a structure

As Stephen Cobeldick helped me yesterday, I have a structure T consisting of 4 fields. I want to calculate the mean of each field in T.. Then I want all them to be written in an excel file. Thnx..

2 Comments

Rik
Rik on 8 Sep 2020
What did you try yourself?
FG
FG on 8 Sep 2020
Tried this but did'nt work.. M = mean([T.HV3])

Sign in to comment.

 Accepted Answer

M = mean(T.HV3)
and then use writematrix.

2 Comments

FG
FG on 8 Sep 2020
It gives a NaN
FG
FG on 8 Sep 2020
Guess I found it..

Sign in to comment.

More Answers (1)

D = structfun(@mean, T);
writetable(table(D), 'Sample.xlsx') % or writematrix() as Stephen suggested

Categories

Products

Release

R2020a

Asked:

FG
on 8 Sep 2020

Commented:

FG
on 8 Sep 2020

Community Treasure Hunt

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

Start Hunting!