Function block is working in Matlab but not in simulink

6 visualizaciones (últimos 30 días)
Michael Erdl
Michael Erdl el 24 de En. de 2019
Comentada: Usman Khan el 23 de En. de 2020
Hi,
I am currently trying myself on some human activity recognition on android. I used the "Human Activity Recognition Simulink Model for Smartphone Deployment" example as a starting point but as I wanted to do other activities and some more amndroid stuff I decided to only reuse some part of the 'slexHARAndroidExample' simulink i.e. the extractFeature block.
My problem is that I cannot simulate my model and if I use the embedded coder to deploy it, it classifys everything the same. Interesting is that it works correctly if I do it in Matlab step by step.
So if I run the following lines in Matlab directly it works fine:
feats = extractFeatures(X_Buff,Y_Buff,Z_Buff);
Act = predict(mdl,feats);
But if I want to simulate it by
Act = sim('ClassME')
with the same X_Buff,Y_Buff,Z_Buff in the workspace I get the following Error:
Index exceeds array dimensions. Index value 0 exceeds valid range [1-2049] of array f. Error in 'ClassME/extractFeatures' (line 133) ofpk = f(olocs); Error in 'ClassME/extractFeatures' (line 62) Error in 'ClassME/extractFeatures' (line 16)
although the code is the same.
Below is my simulink model where extractFeatures and predictActivity are taken from the example, although I trained the model for the predict block with diefferent data.
SimulinkModel.PNG
I am currently using Matlab version R2018b. Do you have any idea or starting point why it behaves like this?

Respuestas (2)

omar sheishaa
omar sheishaa el 27 de Feb. de 2019
i have the same issue when i tried to add the input values statically from an excel file using spreadsheet block in simulink when i tried to run the motion recognition model on the PC
my model is as follow
here is the output
Index exceeds array dimensions. Index value 0 exceeds valid range [1-2049] of array f.
Error in 'slexHARAndroidExample/extractFeatures' (line 133)
ofpk = f(olocs);
Error in 'slexHARAndroidExample/extractFeatures' (line 62)
Error in 'slexHARAndroidExample/extractFeatures' (line 16)

Santhosh A V
Santhosh A V el 14 de Mzo. de 2019
Hi Michael
From the Figure you have provided X_buff,Y_buff,Z_buff appear to be inputs (similar to IN blocks). While the X_buff,Y_buff,Z_buff in HAR example are buffers.It appears that while simulation the input values are not populated. Can you share the model?
Thanks
Santhosh
  1 comentario
Usman Khan
Usman Khan el 23 de En. de 2020
Here is link to the model (https://www.mathworks.com/help/stats/human-activity-recognition-simulink-model-for-deployment.html)
I'm facing the same issue, if you can please guide on it.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by