Got Questions? Get Answers.
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 to vectorise formula

Subject: how to vectorise formula

From: Richard

Date: 8 Aug, 2010 22:52:05

Message: 1 of 4

Hi, having difficulty working out how to vectorise this formula

for j=1:x
sum over h=1:n of U(h)*G(h,j) * sum over t=1:m of (X(h,t)*P(t))/G(h,t)

Any help much appreciated.
thanks.

Subject: how to vectorise formula

From: Roger Stafford

Date: 8 Aug, 2010 23:51:05

Message: 2 of 4

"Richard " <REMOVETHISrcaldwellie@yahoo.com> wrote in message <i3ncel$s9b$1@fred.mathworks.com>...
> Hi, having difficulty working out how to vectorise this formula
>
> for j=1:x
> sum over h=1:n of U(h)*G(h,j) * sum over t=1:m of (X(h,t)*P(t))/G(h,t)
>
> Any help much appreciated.
> thanks.
- - - - - - - - - - - -
  Your expression is somewhat difficult to interpret but does this do what you want?

  ((U(:).*((X./G)*P(:))).')*G

Roger Stafford

Subject: how to vectorise formula

From: Roger Stafford

Date: 9 Aug, 2010 00:48:04

Message: 3 of 4

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3nft9$sc0$1@fred.mathworks.com>...
> Your expression is somewhat difficult to interpret but does this do what you want?
>
> ((U(:).*((X./G)*P(:))).')*G
>
> Roger Stafford
- - - - - - - - - - -
  I just realized that since the same G matrix appears twice in the above expression that implies that x is equal to m. If that is not so, you would have to modify the formula, perhaps something like this:

 ((U(:).*((X./G(:,1:m))*P(:))).')*G(:,1:t)

Roger Stafford

Subject: how to vectorise formula

From: Richard

Date: 9 Aug, 2010 09:19:07

Message: 4 of 4

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3nj84$n2m$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i3nft9$sc0$1@fred.mathworks.com>...
> > Your expression is somewhat difficult to interpret but does this do what you want?
> >
> > ((U(:).*((X./G)*P(:))).')*G
> >
> > Roger Stafford
> - - - - - - - - - - -
> I just realized that since the same G matrix appears twice in the above expression that implies that x is equal to m. If that is not so, you would have to modify the formula, perhaps something like this:
>
> ((U(:).*((X./G(:,1:m))*P(:))).')*G(:,1:t)
>
> Roger Stafford
Hi Roger, thanks. Although the G matrix appears twice, the first time its a specific column vector from G and the second time its the complete matrix. I 'think' I've vectorised it as
(U.*G(:,j))'*(P'*(X(:,:)./G(:,:))')'
the amount of columns in G = t

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