Function block is working in Matlab but not in simulink

조회 수: 6 (최근 30일)
Michael Erdl
Michael Erdl 2019년 1월 24일
댓글: Usman Khan 2020년 1월 23일
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?

답변 (2개)

omar sheishaa
omar sheishaa 2019년 2월 27일
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 2019년 3월 14일
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
Usman Khan
Usman Khan 2020년 1월 23일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by