Home How to return the leaves of a struct as vector in Matlab?
 Often I need to access the leaves of data in a structured array for calculations. How is this best done in Matlab 2017b? % Minimal working example: egg(1).weight = 30; egg(2).weight = 33; egg(3).weight = 34; someeggs = mean([egg.weight]) % works fine apple(1).properties.weight = 300; apple(2).properties.weight = 330; apple(3).properties.weight = 340; someapples = mean([apple.properties.weight]) %fails weights = [apple.properties.weight] %fails too % Expected one output from a curly brace or dot indexing expression, % but there were 3 results.