Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Arrary indexing with vectors ?
Replies: 2   Last Post: Oct 26, 2010 11:14 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Sanghee

Posts: 6
Registered: 10/7/10
Arrary indexing with vectors ?
Posted: Oct 26, 2010 10:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have a quick task in the following.

TBL = round(rand([256,256])*63)+1; % An arrary has random numbers between 1 to 64

M = 2048;

X = round(rand(M)*255)+1; % Vector of size M with random number between 1 to 256
Y = round(rand(M)*255)+1; % Vector of size M with random number between 1 to 256

Now, I want to make an array Z which is a vector of size Mx1, where each entry
has the one like,

Z(1) = TBL(X(1),Y(1));
Z(2) = TBL(X(2),Y(2));
....

Certainly, I can use for loop like,

for j=1:M
Z(j) = TBL(X(j),Y(j));
end

But, is there any way to do this with a simple vector operation ?

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.