From help-request at octave dot org Thu Apr 13 10:41:27 2006 Subject: how do I vectorize this? From: Claudio Belotti To: help at octave dot org Date: Thu, 13 Apr 2006 17:39:21 +0200 Dear all, I have a set of values z spread over an x-y plane I want to average the values on a fixed grid (xi,yi). I use: xidx = lookup(xi,x) yidx = lookup(yi,y) zidx = sub2ind(sizeofgrid, xidx, yidx) and then for i=1:length(zidx) zi( zidx(i)) += z(i) ni( zidx(i)) += 1 endfor zi = zi./ni my question is: how do I vectorize the for-loop above? cheers Claudio -- Claudio Belotti ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------