sum of cellarray of structs

sum of cellarray of structs

Post by stat » Wed, 01 Jul 2009 22:59:03


Hello, I have a difficult problem...(for me)

I have
1. a data cell array and each cell contains a structure...data = {3*1} cell array
2. for i in 1:3 the data{i} as lets say {'x','y','z'} fields which are arrays
data{i}.x ... data{i}.y ... data{i}.z
2. a [3*1] vector of scalars leta say q(1) ... q(2) ... q(3)

I would like to vectorize the follwing operation
ans.x = sum on i of q(i) * data{i}.x
ans.y = sum on i of q(i) * data{i}.y
ans.z = sum on i of q(i) * data{i}.z

do somebody has an idea, may be with cellfun and accumarray I dont know ...