フィルターのクリア

Function knnsearch triggers an error in MATLAB R2021a, which wasn't in R2013b

5 ビュー (過去 30 日間)
Iyad Khuder
Iyad Khuder 2022 年 1 月 5 日
編集済み: Iyad Khuder 2022 年 1 月 5 日
I had a project (related to my PhD research), which was running properly in MATLAB R2013b. Having migrated to v R2021a, I've got an error, triggering from the function knnsearch:
Undefined function 'knnsearch' for input arguments of type 'double'.
at thos code line:
[layer_mIdx, mD] = knnsearch(Vec_layer_Centroids, Vec_layer_Centroids, 'K', K+1, 'Distance', 'minkowski', 'P', 2);
The syntax of the function is: Idx = knnsearch(X,Y,Name,Value)
where X and Y are Input data, specified as a numeric matrix.
In my usecase, X=Y and is an array of doubles, as shown in my workplace:
This array contains the coordinates of a set of 2-D points, which I called "centroids".
Although, I have extracted these coordinates from a culumn of type "cell array", but I think they are extracted as numeric date (as MATLAB recognizes them as doubles in the workspace).
Furthermore, the function worked without any problem in v R2013b, which is frustrating:(
Any help would be appreciated.
Let me know if any further details could help.
Thanks

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 5 日
load hospital;
X = [hospital.Age hospital.Weight];
Y = [20 162; 30 169; 40 168; 50 170; 60 171]; % New patients
Idx = knnsearch(X,Y)
Idx = 5×1
96 96 41 51 20
So knnsearch() still works in R2021b.
However... it is part of the Statistics Toolbox, and perhaps you did not install / license that toolbox when you upgraded.
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 1 月 5 日
You can use that "Get Add-Ons" to install the toolbox.
Iyad Khuder
Iyad Khuder 2022 年 1 月 5 日
編集済み: Iyad Khuder 2022 年 1 月 5 日
Yeeh it works! ^_^
P.S. I first hadn't seen your 2nd comment on how to add the add-on and didn't notice that button :))
I asked Google, and this lead me to install Mathwork products, using its installer... and in the end it wasn't actually added. Then, I saw your hint, and I clicked that "Get Add-Ons" button, and it worked.
Appreciated!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by