Function block is working in Matlab but not in simulink
7 次查看(过去 30 天)
显示 更早的评论
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.
I am currently using Matlab version R2018b. Do you have any idea or starting point why it behaves like this?
0 个评论
回答(2 个)
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)
0 个评论
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
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!