Can't get new orientlog values.
Show older comments
Ok so I am trying to get real time values from my android using the matlab app. The problem if I use m.Orientation there is a lot of lag. Then a user suggested I use orientlog(m) ie. logging but the problem when I run my code I get the error "Undefined function 'discardlogs' for input arguments of type 'double'." and "Error in Sensor_data_gimbal (line 35) discardlogs(m)". If I don't discard the log and make change to my second for loop so that it only runs only the last 10 values I get the error "Undefined function 'orientlog' for input arguments of type 'double'." and "Error in Sensor_data_gimbal (line 14) [o] = orientlog(m)". Can someone tell me why I keep getting this error? And is it possible to get the sensor data from the android app via USB cable??
CODE:-
clear all clc
connector on;
m = mobiledev(); m.OrientationSensor = 1; m.Logging = 1; pause (4)
for c = 1:inf
[o] = orientlog(m)
[m]=size(o,1)
pause(0.01);
for i = 1:m
if o(1) < 40
disp('yup')
elseif o(1) > 60
disp('nope')
elseif o(1) > 40 && o(1) < 60
disp('hmmm')
end
if o(3) < -10
disp('yup')
elseif o(3) > 10
disp('nope')
elseif o(3) < 10 && o(3) > -10
disp('hmmm')
end
end
discardlogs(m)
end
Answers (1)
Wiktor M
on 7 May 2019
0 votes
You have overwritten variable m with output of 'size' function. just nuemrical.
What should have been done was set "m=mobiledev" at te beginning and leave it as it is.
Function discardlogs(m) works properly (for me too, I use it a lot at the moment) when takes mobiledev structures, not numerical.
See that Your first line is taking set object 'm', that was properly set as mobiledev if did not output any error there.
Categories
Find more on Sensor Data Collection 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!