ReadMotionData.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function M = ReadMotionData (file)
  2. % reading the csv from a given filename and plot the gyroscope and the accelerometer
  3. % in two seperate figures. It also marks the touch events as circles
  4. GYRO_X = 2;
  5. GYRO_Y = 3;
  6. GYRO_Z = 4;
  7. ACC_X = 6;
  8. ACC_Y = 7;
  9. ACC_Z = 8;
  10. M = csvread(file, 2, 0);
  11. length = size(M,1);
  12. x_axis = 1:length;
  13. % Plot results
  14. fig1 = figure;
  15. plot(x_axis, M(:,GYRO_X))
  16. hold on
  17. plot(x_axis, M(:,GYRO_Y))
  18. plot(x_axis, M(:,GYRO_Z))
  19. % add the ACTION DOWN events to the plot
  20. indices = find(M(:,9) == 1);
  21. %returns a Nx1 array
  22. indices = indices';
  23. y_values = zeros(1, size(indices,2));
  24. scatter(indices, y_values);
  25. title('Gyroscope Values - Right/left/bottom')
  26. legend({'GYRO_X', 'GYRO_Y', 'GYRO_Z'})
  27. hold off
  28. %Start the second figure for the acceleration sensor measurements
  29. fig2 = figure;
  30. plot(x_axis, M(:,ACC_X))
  31. hold on
  32. plot(x_axis, M(:,ACC_Y))
  33. plot(x_axis, M(:,ACC_Z))
  34. scatter(indices, y_values);
  35. title('Acceleration Values - Right/left/bottom')
  36. legend({'ACC_X', 'ACC_Y', 'ACC_Z'})
  37. hold off
  38. end