[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Vectorize this loop?
From: |
Matthias Brennwald |
Subject: |
Vectorize this loop? |
Date: |
Fri, 24 Oct 2008 09:42:34 +0200 |
Dear Octavers
Is it possible to get rid of the for loop in the below code by replacing
it by some vectorized code? I somehow think it is, but I can't see how.
Any ideas would be appreciated.
Thanks
Matthias
--------------------
point_count = round (rand(1000,1))*5 + 20; % this is just a dummy to
illustrate the problem.
N_vals = sum (point_count);
N_scans = length (point_count);
scan_idx = repmat (NaN,N_vals,1);
ind = cumsum (point_count); ind = [0 ; ind];
for ii = 1:N_scans
scan_idx (ind(ii)+1:ind(ii+1)) = ii;
end
--------------------
- Vectorize this loop?,
Matthias Brennwald <=