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:
Help with vectorizing where the indices of a matrix are found from another matrix

Subject: Help with vectorizing where the indices of a matrix are found from another matrix

From: Brendan

Date: 25 Feb, 2010 01:07:06

Message: 1 of 1

Hello,

I'm having trouble figuring out how to vectorize the following efficiently

EofGgivenXjU=zeros(numVars,maxDisc);
for ii=1:length(GofX)
    for jj=1:numVars
        EofGgivenXjU(jj,D(ii,jj))=EofGgivenXjU(jj,D(ii,jj))+newTermU(ii);
    end
end

Thank you very much

Brendan

In this case,

D =

     5 4
     5 3
     5 7
     3 1
     2 2
     2 2
     1 7
     3 5
     2 7
     5 7
     4 6
     2 4
     2 6
     4 1
     2 2
     4 6
     5 1
     2 4
     2 3
     1 6
     3 5
     3 1
     2 7
     5 3
     4 4
     5 7
     1 7
     3 2
     2 5
     5 5
     3 7

newTermU =

   16.1735
   15.1973
   26.9150
    8.2309
    2.1006
    2.1006
   14.7779
    8.2898
   15.5143
   26.9150
   18.1930
    2.0645
   10.1033
   13.2122
    2.1006
   18.1930
   18.7264
    2.0645
    1.0306
    9.2027
    8.2898
    8.2309
   15.5143
   15.1973
   10.3268
   26.9150
   14.7779
    5.3185
    5.1159
   18.8602
   19.8829

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