From: james bejon on 18 Apr 2010 20:42 I was hoping someone could help me out. I'm happy enough (I think) with using something like R(R > 0) = 0; when I want to 'zero-out' all the positive elements of a vector. But how do I generalise this idea? To give a more specific example, suppose I have r = rand(4, 5, 6, 7); and I want to zero-out all the occasions where, say, sum(r(:, :, 1:3, :), 3) > sum(r(:, :, 4:6, :), 3). I can't work out how to do such a thing.
From: Roger Stafford on 18 Apr 2010 21:40 "james bejon" <jamesbejon(a)yahoo.co.uk> wrote in message <hqg8ss$nfi$1(a)fred.mathworks.com>... > I was hoping someone could help me out. I'm happy enough (I think) with using something like > > R(R > 0) = 0; > > when I want to 'zero-out' all the positive elements of a vector. But how do I generalise this idea? To give a more specific example, suppose I have > > r = rand(4, 5, 6, 7); > > and I want to zero-out all the occasions where, say, sum(r(:, :, 1:3, :), 3) > sum(r(:, :, 4:6, :), 3). I can't work out how to do such a thing. I would think it would be something like this: t = sum(r(:,:,1:3,:),3)>sum(r(:,:,4:6,:),3); r(repmat(t,1,1,6,1)) = 0; Roger Stafford
From: james bejon on 19 Apr 2010 13:23 Of course. Thanks Roger.
|
Pages: 1 Prev: PID controller using GA toolbox Next: How to recognize objects which have very similar color? |