종종 계산을 위해 구조화 된 배열의 데이터 잎에 액세스해야합니다. Matlab 2017b에서 이것이 가장 잘된 방법은 무엇입니까?구조체의 잎을 Matlab에서 벡터로 반환하는 방법은 무엇입니까?
% 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.
예를 들어, 또는 임의의 구조를 원하십니까? – gnovice
'a (k) .b.c .... z' 형식의 구조체에 대한 @gnovice는'z (k)'를 원한다. 예제를 추가했다. 그러나 구조에 적용하기 위해 솔루션의 비트를 약간 변경해야한다면 괜찮습니다. –