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

Rik
Rik 2019년 5월 22일
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
Image Analyst 2019년 5월 22일
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
Hanafi Akmal 2019년 5월 22일
Image Analyst
So basically, out of 210 rows will divided into 5 rows, which will divided to 80% train and 20% test. Which make 4 rows for train and 1 row for test. So the total of data train will 168 and 42 for data test. And i trying to figure out the minimum distance between train and test data.
z.JPG
this is example of my data of 210x12.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

질문:

2019년 5월 22일

댓글:

2019년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by