Search code examples
arraysmatlabcell

addressing cell arrays of structures


I have following cell array:

res{1}.nft.x=1;
res{2}.nft.x=2;
res{3}.nft.x=3;

How can I easily get an array of nft.x values, i.e., [1 2 3] in this case?

Thanks!


Solution

  • use cellfun

    >> cellfun( @(x) x.nft.x, res )