[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how synchronize array elements?

From: Jordi Gutiérrez Hermoso
Subject: Re: how synchronize array elements?
Date: Fri, 23 Nov 2007 12:56:49 -0600

On 22/11/2007, DushanM <address@hidden> wrote:
> I have two differently-dimensioned arrays, A and B, whose sizes are
> M x N and 3 x M x N respectively (the first index of B refers to
> the components of a 3-vector).  Now I want to do some operations
> such as multiply the vectors in B by the corresponding scalar in A:
>     A(k,l) * B(:,k,l)  ,       k = 1:M,   l = 1:N
> where the 'k' values are identical in A and B and likewise for 'l'.


     for n =1:3
       B(n,:,:) = A.*squeeze(B(n,:,:));

Yeah, yeah. It's a for-loop, but with only three passes of the loop,
you shouldn't notice a slowdown. ;-)

- Jordi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]