MATLAB: Multi-level indexing

multi-level indexingscalar index

Hi! I have this structure "result.pops(1:1000,1:20).obj(1:2)"
I want to make addition of 2 value (obj(1) + obj(2)), of all pops file. I expect a matrix size 1000×20 where each case are sum of obj 1 and 2… I get this error " Scalar index req. for this type of multi-level indexing"
I usualy use "For" loop to execute the job but I want to learn the good way to make it faster
Thank you for your suggestion!

Best Answer

struct2cell(), cell2mat(), sum() on the appropriate dimension.