View and Replay Map Data
This example shows how to use the map visualization in the Simulation Data Inspector to view routes of longitude and latitude data. The map data is synchronized with signal data, which allows you to analyze signal activity throughout the route by adding cursors and by replaying the data.
The map visualization used in this example is also available in the Record block. When you use the map visualization in the Record block, you add the visualization and configure the appearance using the toolstrip. You plot data on the map the same way shown in this example.
To view map data in the Simulation Data Inspector or Record block, you must have an active internet connection.
Import Route Data into Simulation Data Inspector
If your model includes latitude and longitude signals, you can view logged data on the map during simulation. You can also import data from the workspace or a file.
Open the Simulation Data Inspector.
The data for this example is stored in the Excel™ file
LoganTripGPSData.xlsx. To import the data using the user interface, click Import .
In the Import dialog box, under Import from, select File. Then, enter
LoganTripGPSData.xlsx in the text box and click Import.
Alternatively, import the data programmatically using the
mapRun = Simulink.sdi.createRun("LoganTrip","file","LoganTripGPSData.xlsx");
Plot Route on Map
By default, the Simulation Data Inspector uses time plots for each subplot in the layout. To plot data on a map, you need to add the visualization to the layout.
To add a map to your layout, click Layout . Then, select Edit View.
From the Visualization Gallery, drag the Map icon onto the subplot.
When you finish updating the visualization for subplots in your layout, close the Visualization Gallery.
Alternatively, you can modify the visualization for a subplot using the subplot menu. Pause on the subplot where you want to change the visualization, then click the three dots that appear. From the Change Visualization drop-down list, select the visualization you want to use for that subplot.
To plot a route on the map, select the signal with the latitude data and the signal with the longitude data in the table and drag them onto the map. Hold the Shift key or the Ctrl key to select more than one signal row in the table. For this example, select the rows for the
logan_lat signal and the
logan_long signal in the table, then drag the selection onto the map.
Specify which signal to use as the latitude data and which to use as the longitude data in the route menu that appears in the lower-right of the plot.
After making the selections, click OK.
Plot Signal Data Alongside Route
Change the subplot layout in the plot area to a
1 layout so you can plot the speed data alongside the route. Click Layout . Then, under Basic Layouts, select the subplot layout in a
To plot the speed data on the bottom subplot, select the subplot, then select the check box next to the
speed signal in the table.
Analyze Data Using Cursors
You can add cursors to the plots to analyze the relationship between the
speed signal and the route shown on the map. To add two cursors to the layout, click the drop-down arrow on the Show/hide data cursors button and select Two Cursors.
When you add cursors, extra markers appear on the map. The start and end points for the route have static markers, and an additional marker corresponds to each cursor. Move the cursor on the left. The marker on the right of the map moves as you move the left cursor because the route starts in Boston and moves from East to West over time.
To remove the cursors from the plot, click Show/hide data cursors .
Replay Route and Signal Data
In the Simulation Data Inspector, you can replay data to analyze relationships among plotted signals in your view. When you replay data in the Simulation Data Inspector, animated cursors sweep through the plotted data from the start time to the end time. To add the replay controls to the view, click Show/hide replay controls .
Then, click Replay .
A marker on the map and a cursor on the time plot sweep synchronously across the screen.
By default, the Simulation Data Inspector replays data at one second per second, meaning that the cursor moves through one second of data in one second of clock time. The data for this trip spans approximately 34 minutes. You can increase the replay speed using the arrow to the right of the label or by clicking the label and typing the desired speed. Increase the replay speed to
32x using the arrow.