How can I overcome a persistent mxArray error in Simulink (MATLAB Function Block)?
Mostrar comentarios más antiguos
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 comentario
Jean-Pierre Asdiguian
el 10 de Abr. de 2022
Editada: Walter Roberson
el 10 de Abr. de 2022
Respuestas (1)
Walter Roberson
el 10 de Abr. de 2022
0 votos
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 comentarios
Jean-Pierre Asdiguian
el 10 de Abr. de 2022
Walter Roberson
el 10 de Abr. de 2022
Editada: Walter Roberson
el 10 de Abr. de 2022
You will probably also need to use the %#function pragma mentioning the name of the class
%#function ClassificationKNN
Categorías
Más información sobre Signal Attributes and Indexing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!