Vector and Matrices comparison

2 views (last 30 days)
Ali Ali
Ali Ali on 2 May 2018
Answered: Star Strider on 2 May 2018
Hi,
I want to find the closest column to a vector and name the index of the column?
V =
0.320373395974224
0.343657408330863
0.0647635831054113
0.611246744787932
0.252543893010251
0.836651172399228
0.433132105815962
0.267252371218910
N =
0.843193555110595 0.0264000151356882 0.843929139772920 0.992086798255982
0.395105201566654 1.05039660938666 -0.0923156103168576 -0.000828850484347887
0.833340055022349 1.21116338190365 0.435817502517243 0.0928679524432253
0.721942976971473 0.0229586112613379 1.02469878021803 0.985841211841693
0.532957436613246 -0.0103493752471847 0.627547000618107 1.07676510721568
0.815457856716130 0.940451590084812 0.462335032896403 -0.0772672497132867
0.812823496795477 1.13990527774124 0.651114276529232 -0.00236099683556623
-0.00952043153750615 0.0382778981334200 -0.146625708734782 0.978428808245543
  2 Comments
Guillaume
Guillaume on 2 May 2018
What is your definition of closest?
Ali Ali
Ali Ali on 2 May 2018
nearest column values to the vector

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 2 May 2018
Use the pdist2 (link) function.
Example
D = pdist2(V', N', 'euclidean','Smallest',1)
[~,ClosestCol] = min(D)
Note the transposition operators (').

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!