Optimization of 2 matrices
Show older comments
Hi Guys,
I need to solve a problem. I have an idea to do that, just am confused about which functions to use to implement the idea.
So I have 2 matrices. Each matrix contains n rows and 2 columns. The matrix is essentially the x and y co-ordinates of n points. Matrix 1 consists of the co-ordinates at time 't' and Matrix 2 at time 't+Δt'.
The idea.
1.I want to find all possible combinations of the elements in matrix 1 with matrix 2. Since I have 'n' rows, I will have 'n!' combinations.
2. After finding the combinations, I want to calculate the distance between the two points. I use the default formula i.e sqrt((x1-x2)^2+(y1-y2)^2).
3. So i ll have n! n*1 distance matrices. I want to add all the elements in one matrix and then find the matrix that has the least total value amongst all n! matrices.
4. Now the matrix that has the least total distance, I want to take the second matrix (that led to that combination) in my forward calculation.
I am stuck in steps 1, 2 and the final correspondence in step 4. Could anyone tell me what functions I could use to serve my purpose.
Thanks. NS.
I hope I explained the problem clearly.
To simplify things,
if [a b c] and [d e f] are my initial matrices with a-f being the coordinates of points. The matrices are column matrices and should actually contain 2 columns. I have just simplified it. The possible combinations will be [ad be cf], [ad bf ce], [ae bd cf], [ae bf cd], [af bd ce], [af be cd]. After steps 3 and 4, I find that [ae bd cf] gives me the least distance. I want to take the matrix [e d f] in my forward calculations.
4 Comments
bym
on 23 May 2011
I don't think your simplification adds anything, in fact it confuses me. You state the matrix 1 & 2 are nx2, yet your example is 1x3??
NS
on 24 May 2011
John D'Errico
on 24 May 2011
Um, wrong. Since you have two matrices with n rows in each, all possible combinations will be n^2, NOT n!, i.e., not factorial(n).
NS
on 24 May 2011
Accepted Answer
More Answers (0)
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!