Created
September 11, 2015 18:15
-
-
Save rysk-t/7720cedef7515ec0b8db to your computer and use it in GitHub Desktop.
matlab mobile with matlab2015; acceralation & orientation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ~exist('m') | |
m = mobiledev() | |
end | |
i=1; | |
tic | |
close all | |
clear t x | |
while true | |
subplot(121) | |
ori = m.orientation*pi/180; | |
plot([0 cos(ori(1))], [0 -sin(ori(1))]) | |
xlim([-1 1]) | |
ylim([-1 1]) | |
zlim([-1 1]) | |
viscircles([0 0], 1) | |
grid on; axis image | |
subplot(122) | |
acc = abs(m.Acceleration); | |
acc(3) = acc(3)-9.8; | |
accR = sum(acc); | |
x(i) = accR; | |
t(i) = toc; | |
plot(t, x, '-'); hold on; grid on | |
plot(t(end)', x(end), 'd') | |
%ylim([-1 1]*max(x)) | |
if i>501 | |
xlim([t(i-500) t(i)+1]) | |
end | |
hold off | |
i = i+1; | |
pause(0.01) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment