How can I overcome a persistent mxArray error in Simulink (MATLAB Function Block)?
古いコメントを表示
Hello everyone!
As the title states, I have a problem with an mxArray error that I keep getting.
"Attempt to extract field 'NumNeighbors' from 'mxArray'."
Now, of course I did try to look up on how to overcome it, and the key is to initialize the object/variable that I am using. I actually did that with one of my data variables (using struct), and problem was solved. The problem with this second variable is that I don't even know how exactly I am to initialize it. The code that I'm trying to execute is:
clmod = fitcknn(data, 'Rank~Grade_grd_+Age_');
The thing that I am trying to do is to upload this code into a microcontroller afterwards (Arduino, Raspberry Pi), and the code, on its own as a MATLAB script, works perfectly fine, so I decided to convert it slowly to Simulink. This is the point where I'm currently stuck on. What can I do to make this function work inside a MATLAB Function Block? And yes, I do have the coder.extrinsic already layed out for every external function I'm using. What is something that I may try?
Thank you very much, and my apologies for the trouble in advance.
1 件のコメント
Jean-Pierre Asdiguian
2022 年 4 月 10 日
編集済み: Walter Roberson
2022 年 4 月 10 日
回答 (1 件)
Walter Roberson
2022 年 4 月 10 日
0 投票
If you were able to convert over to using Interpreted execution mode, then that would be something that you would not be able to deploy to a microcontroller, as microcontrollers cannot run interpreted MATLAB.
The general hypothesis is that you should not be doing fitting on the Microcontroller: that you should instead already have fit before hand, and saved the fit coefficients, and then the fit coefficients can be loaded into the microcontroller for use in prediction or classification.
2 件のコメント
Jean-Pierre Asdiguian
2022 年 4 月 10 日
Walter Roberson
2022 年 4 月 10 日
編集済み: Walter Roberson
2022 年 4 月 10 日
You will probably also need to use the %#function pragma mentioning the name of the class
%#function ClassificationKNN
カテゴリ
ヘルプ センター および File Exchange で Signal Attributes and Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!