I get an error in knnsearch

3 vues (au cours des 30 derniers jours)
Ray
Ray le 5 Déc 2015
Commenté : Walter Roberson le 6 Déc 2015
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 commentaire
Ray
Ray le 5 Déc 2015
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

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Déc 2015
[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 commentaires
Ray
Ray le 6 Déc 2015
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 le 6 Déc 2015
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by