[Top][All Lists]

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

Re: how synchronize array elements?

From: DushanM
Subject: Re: how synchronize array elements?
Date: Fri, 23 Nov 2007 22:02:23 -0700
User-agent: MacSOUP/2.8.1 (Mac OS X version 10.4.11 (x86))

Jordi GutiƩrrez Hermoso <address@hidden> wrote:

> 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'.
> Try
>      for n =1:3
>        B(n,:,:) = A.*squeeze(B(n,:,:));
>      endfor
> Yeah, yeah. It's a for-loop, but with only three passes of the loop,
> you shouldn't notice a slowdown. ;-)
Thanks, Jordi, I was suspecting more and more that that was the only
reasonable way to do it.  Nothing else I tried worked.

- Dushan

reply via email to

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