I get an error in knnsearch

조회 수: 3 (최근 30일)
Ray
Ray 2015년 12월 5일
댓글: Walter Roberson 2015년 12월 6일
rec_syms = knnsearch([real(symbol_book) imag(symbol_book)], [real(X_hat) imag(X_hat)]) - 1;
I get this error:
Error using KDTreeSearcher/knnsearch (line 74)
Y must be a matrix with 8 columns.
Error in knnsearch (line 142)
idx = knnsearch(O,Y,'k',numNN, 'includeties', includeTies);
Error in OFDM_image (line 139)
rec_syms = knnsearch([real(symbol_book) imag(symbol_book)], [real(X_hat) imag(X_hat)]) - 1;
  댓글 수: 1
Ray
Ray 2015년 12월 5일
Thanks for your response. symbol_book is 1x4 matrix which has the QPSK reference quadrants {0.7071+0.7071i, -0.7071+0.7071i, -0.7071-0.7071i, 0.7071-0.7071i}. Now, the x_hat is the estimated data with 50000x1 matrix. What i am trying to do is find the min distance between the QPSK reference and the actual received data. Not sure if maybe when i switched to 2015 matlab would have an effect! please advise

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

채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 5일
[real(symbol_book) imag(symbol_book)] together makes a matrix with 8 columns, such as if there are 4 columns in symbol_book. But [real(X_hat) imag(X_hat)], the locations to search for, does not have 8 columns. The locations to search for (the second parameter) must have the same number of columns as the first parameter.
  댓글 수: 3
Ray
Ray 2015년 12월 6일
I changed it per your suggestion and it worked. can you explain to me what was wrong before and how this change fixed the problem.
Walter Roberson
Walter Roberson 2015년 12월 6일
You had a row vector of 4 elements. real() of that is something that is 1 x 4. imag() of it was also 1 x 4. []'ing those together resulted in something 1 x 8. Your set of points to be searched through was therefore a single point with 8 dimensions. But that is not what you wanted: you wanted 4 points with two dimensions. Using symbol_book(:) reshapes from 1 x 4 to be 4 x 1. Use [] to put two 4 x 1 together and you get 4 x 2 -- 4 points each with 2 dimensions.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Classification Ensembles에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by