The paperchase exercise is intended to help students to understand how to use sensors of mobile devices connected to a server via MATLAB Mobile.
Exercise “MATLAB Mobile GPS Paperchase”
- Use a smartphone or tablet computer with GPS and SIM card installed. Use MATLAB Mobile to connect your iOS or Android device to your computer in the classroom. Start logging your GPS location on your computer while you walk.
- Find the first GPS location (e.g. Lat 52.408071 Lon 12.973718) on your mobile device. At this location you will find a piece of paper hanging on the wall with the next coordinates on. At the penultimate location you will find a person who will tell you the last coordinates and a password. At last location you will get a free coffee if you know the password.
- Return to the classroom, stop logging the GPS coordinates and display the path you walked in OpenStreetMap.
Solution “MATLAB Mobile GPS Paperchase”
- You will need a smartphone or tablet computer with GPS and SIM card installed. You need to download and install the following apps on your iOS or Android mobile device: CISCO AnyConnect and MATLAB Mobile. You need to download and install the following software, in addition to MATLAB, on your desktop or laptop computer: MATLAB Support Package for Apple iOS Sensors or MATLAB Support Package for Android Sensors.
- Connect your smartphone to your computer using MATLAB Mobile using the instructions of MATLAB Mobile and the MATLAB Support Package for mobile devices. At the U Potsdam you need to establish an VPN connection using CISCO AnyConnect to connect your mobile device to your computer in the classroom.
- Which sensors of your smartphone can be used with MATLAB Mobile? How do you turn them on? How do you start recording them?
- Display this point (e.g. Lat 52.408071 Lon 12.973718) using a map app such as Google Maps App and walk to this location while logging the GPS coordinates via mobile internet on your computer in the classroom. After the last location return to the classroom and stop logging the GPS coordinates.
- Plot your path on the georeferenced map or an OpenStreetMap on your desktop or laptop computer.
Download the MATLAB script and example file.
Solution “MATLAB Mobile GPS Paperchase” – Update November 2019
Unfortunately, MathWorks cut the connection between MATLAB Mobile and MATLAB Desktop. There are now several ways to run the paper chase experiment without this connection:
Solution 1:
- We upload the script to the MATLAB Drive. We then launch the MATLAB Mobile app on the smartphone. In the app we first click on the More button on the menu bar, then we choose Settings from the list and connect the app to the MathWorks Cloud using the MathWorks account. Also in the More menu we then choose Sensors and select Stream to MATLAB at the bottom of the page.
- Then we choose File from on the menu bar, browse the directories and select the script to run the experiment. Unfortunately the script must change in three ways in order to be used with MATLAB Mobile: (A) the webmap function is not available with MATLAB Mobile we have to disable/comment out the commands to create a web map, (B) we cannot evaluate sections in MATLAB Mobile and therefore we have to add the command pause(2) to pause the script for 2 seconds after switching on the sensor with m.Logging = 1. Otherwise the time between m.Logging = 1 and m.Logging = 0 is to short to record any GPS coordinates. On the other hand, MATLAB Mobile will not allow us to record sensor data longer than 2 seconds, i.e. pause(5) causes an error message. Unfortunately even including pause(2) in a for loop won’t work, possibly because MathWorks has implemented a control loop to prevent misuse of the cloud by endless loops. But we can avoid this this by writing the switching on and off of the sensor into the loop. Thus the measured values are no longer equidistant in time. But because a timestamp is also recorded, we can determine these times and correct them if necessary.
- We then push the green triangle at the top of the app window to evaluate the script. Pushing the Commands button on the menu and typing whos after the prompt reveals that we successfully recorded four lon/lat positions which is of course not enough for the paper chase experiment. However, we can export the data with save paperchase.mat to the MATLAB Drive. From there we can import the data into MATLAB Desktop using load paperchase and use the code to create a web map to display the data with OpenStreetMap.
Solution 2:
- The second option after switching off the connection between MATLAB Mobile and MATLAB Desktop is to completely dispense with the use of a MATLAB script. Instead, MATLAB Mobile is only used to record the data on the smartphone. For this we choose Sensors from the More menu, then we select Log instead of Stream to MATLAB. We then push the START button and record the data for a desired time, e.g. 2 minutes. Here we have no time limit, so we can record GPS data during the whole paperchase experiment.
- After pushing the STOP button we are asked to Enter log name in a pop-up window of the app. We define a file name and push the Save button. The app saves the data in the MATLAB cloud. We again import the data into MATLAB and use the code to create a web map to display the data with OpenStreetMap.
Solution 3:
- Use ThingSpeak, there you can use the start.m script to start logging, use stop.m to stop logging, then use map.m to display the results on a computer (download scripts).

