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:
Building a graph based on KNN

Subject: Building a graph based on KNN

From: John P

Date: 25 Jun, 2013 12:52:07

Message: 1 of 1

Here is my code so far:
xTrain is 799x256
I have computed the distance between the individual elements using the following code.
xTrainP = xTrain*xTrain.';
xTrainD = diag(xTrainP)
xTrainP = sqrt(bsxfun(@plus,xTrainD,xTrainD.')-2*xTrainP);

I now have a matrix xTrainP that is a distance matrix with 0's on the diagonal. Each row is a node of the graph and I need to connect the nodes based on KNN = 3,5 etc.

My Question is do I sum the elements of each of the row vectors and then compare the difference between them and say for K=3 conclude that they are 3 most closest node. I am newbie at this type of work and would be grateful for any help.

Thanks

Tags for 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