Thread Subject:
Using all elements in a matrix for calculation / Indexing Question

Subject: Using all elements in a matrix for calculation / Indexing Question

From: Felix

Date: 10 Jan, 2011 14:26:04

Message: 1 of 2

Dear all,

I have a matrix of size 200 X 2 consisting of some coordinates. I have an expression for which I need to use every single pair of elements possible (x,y) i.e. 40 000 different combinations.

Could someone please advise me how to set up the code whilst avoiding the use of for loops.

Thanks a lot,

FW

Subject: Using all elements in a matrix for calculation / Indexing Question

From: Sean de

Date: 10 Jan, 2011 14:37:04

Message: 2 of 2

"Felix" wrote in message <igf4ts$pej$1@fred.mathworks.com>...
> Dear all,
>
> I have a matrix of size 200 X 2 consisting of some coordinates. I have an expression for which I need to use every single pair of elements possible (x,y) i.e. 40 000 different combinations.
>
> Could someone please advise me how to set up the code whilst avoiding the use of for loops.
>
> Thanks a lot,
>
> FW

help meshgrid
[xx yy] = meshgrid(X(:,1),X(:,2));

then use sub2ind, to index
help sub2ind

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
sub2ind Sean de 10 Jan, 2011 09:39:36
meshgrid Sean de 10 Jan, 2011 09:39:36
subscripts curoch 10 Jan, 2011 09:29:23
indexing curoch 10 Jan, 2011 09:29:23
rssFeed for this Thread

Contact us