Filter löschen
Filter löschen

Function block is working in Matlab but not in simulink

5 Ansichten (letzte 30 Tage)
Michael Erdl
Michael Erdl am 24 Jan. 2019
Kommentiert: Usman Khan am 23 Jan. 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?

Antworten (2)

omar sheishaa
omar sheishaa am 27 Feb. 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 am 14 Mär. 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 Kommentar
Usman Khan
Usman Khan am 23 Jan. 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.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by