Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how do I vectorize...

Subject: how do I vectorize...

From: Paul Wiggins

Date: 12 Sep, 2010 16:16:09

Message: 1 of 3

Hi Guys,

   I'm struggling to vectorize the expression:

E_i = \Sum_{jk} I_{ij} A_{jk} I_{ik}

Clearly

E = diag(I*A*I') would work but the i dim is really large so it seems like this would be significantly less than optimal.

Thanks,

Paul

Subject: how do I vectorize...

From: Roger Stafford

Date: 12 Sep, 2010 17:14:04

Message: 2 of 3

Paul Wiggins <pawiggins@gmail.com> wrote in message <146182958.83257.1284308199566.JavaMail.root@gallium.mathforum.org>...
> Hi Guys,
>
> I'm struggling to vectorize the expression:
>
> E_i = \Sum_{jk} I_{ij} A_{jk} I_{ik}
>
> Clearly
>
> E = diag(I*A*I') would work but the i dim is really large so it seems like this would be significantly less than optimal.
>
> Thanks,
>
> Paul
- - - - - - - -
Ei = I(i,:)*A*I(i,:).'

Roger Stafford

Subject: how do I vectorize...

From: Roger Stafford

Date: 12 Sep, 2010 19:06:05

Message: 3 of 3

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i6j1os$5bl$1@fred.mathworks.com>...
> Paul Wiggins <pawiggins@gmail.com> wrote in message <146182958.83257.1284308199566.JavaMail.root@gallium.mathforum.org>...
> > Hi Guys,
> >
> > I'm struggling to vectorize the expression:
> >
> > E_i = \Sum_{jk} I_{ij} A_{jk} I_{ik}
> >
> > Clearly
> >
> > E = diag(I*A*I') would work but the i dim is really large so it seems like this would be significantly less than optimal.
> >
> > Thanks,
> >
> > Paul
> - - - - - - - -
> Ei = I(i,:)*A*I(i,:).'
>
> Roger Stafford
- - - - - - -
  I didn't fully comprehend what you were asking. Apparently you want the full E vector, not just a single component of it at index i. Do this instead:

 E = sum((I*A).*I,2);

  (I assume that I does not denote the identity matrix.)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us