I get an error in knnsearch

3 次查看(过去 30 天)
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