Develop GUI using accelerometer sensor in mobile phone to collect data, filter signal, and show peaks in the signal on the mobile phone
3 views (last 30 days)
Show older comments
I am facing these errors when i try to run
=== Simulation (Elapsed: 4 sec) ===
Error:Index expression out of bounds. Attempted to access element 3. The valid range is 1-1.
More information
Function 'MATLAB Function2' (#109.51.52), line 3, column 20:
"3"
Launch diagnostic report.
Error:Undefined function or variable 'z'. The first assignment to a local variable determines its class.
Function 'MATLAB Function2' (#109.196.197), line 10, column 30:
"z"
Launch diagnostic report.
Error:Errors occurred during parsing of MATLAB function 'john4/MATLAB Function2'
Error:Simulink cannot determine sizes and/or types of the outputs for block 'john4/MATLAB Function2' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Error:Simulink cannot determine sizes and/or types of the outputs for block 'john4/MATLAB Function2' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Error:Port width mismatch. Input 'Acceleration' expects a signal of size 1. The signal received is of size [1x1].
run the build on my mobile phone,
0 Comments
Answers (1)
Walter Roberson
on 12 Mar 2023
You have the Android X Y Z sensors. You extract Z from that -- a scalar. You have the Android button sensor. You extract status (pushed or not) from that -- a scalar. You multiply the scalar Z by the scalar button status, getting a scalar out. You pass that to Accleration function which does
function b = fcn(Acceleration)
z = Acceleration(:,3);
However the input is the scalar, z times button state, rather than being something with three columns.
b = filter(sgolay_coeffs, 1, z);
You have a scalar z, not a history of z. Applying a filter to a scalar is not going to do much good.
You need to use something like a buffer block; see https://www.mathworks.com/matlabcentral/answers/353831-using-savitzky-golay-filter-in-real-time-simulink-model#answer_279467
0 Comments
See Also
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!