How to plot minimum distance.
Mostrar comentarios más antiguos
So I have data set 210x12. I divided by 80% for train and 20%test. I calculated minimum distance with Euclidean equation.
for i=1:length(dataTrain)
%compute euclidean distances
distances = sqrt(sum(bsxfun(@minus, dataTest, dataTrain(i,:)).^2,2));
%minimum distances
minD(i,:)= dataTest(distances==min(distances),:);
end
how do i plot the minimum distance and how do i want to it is the correct equation and plotting.
3 comentarios
Rik
el 22 de Mayo de 2019
I don't know if I fully understand what you're going for, but it looks like you should be using the index output of min instead:
%replace this:
minD(i,:)= dataTest(distances==min(distances),:);
%with this:
[~,idx]=min(distances);
minD(i,:)= dataTest(idx,:);
And shouldn't you square your values before subtracting them to find the hypotenuse?
Image Analyst
el 22 de Mayo de 2019
What do the rows and columns represent? Are you trying to find out which row of your test is closest to each row of your training?
Maybe you should use pdist2().
Hanafi Akmal
el 22 de Mayo de 2019
Respuestas (0)
Categorías
Más información sobre Signal Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
