|
From: | Bill Denney |
Subject: | Re: Efficient Octave Code |
Date: | Sat, 21 Oct 2006 10:28:20 -0400 |
User-agent: | Thunderbird 1.5.0.7 (Windows/20060909) |
rockster8 wrote:
Well, first off, since you're multiplying 0 (F) times a boolean, Fk will always be zero, soI've got a nested for-loop and was wondering if there is an octave-equivalent notation that will simplify the for-loop: for i=1:50 for j=1:50 for k=1:10 Fk(i,j) = F(i,j) .* (w(i,j) == k); end end end where the following are initialized as: Fk(1:50,1:50) = 0; F(1:50,1:50) = 0; w(1:50,1:50) = randomly generated numbers..
Fk = zeros (size (F)); would work. Assuming that F weren't 0, you could do something like this: for k = 1:10 mask = (w == k); Fk(mask) = F(mask); endfor Bill
[Prev in Thread] | Current Thread | [Next in Thread] |