This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Visualize Peaks in Your Data

This example shows how to visualize the peaks (local maxima) in your data in ThingSpeak™ channel.

Read Car Counter Data from ThingSpeak Channel

The car-counter ThingSpeak channel uses a Raspberry Pi™, and a webcam to count cars on a busy highway. A car-counting algorithm is running on the Raspberry Pi, and the number of cars counted every 15 seconds is sent to ThingSpeak. Use the thingSpeakRead function to read the last 120 data points for eastbound traffic from channel 38629.

data = thingSpeakRead(38629,'NumPoints',120,'Fields',2,'outputFormat','table');

Find Peaks

The highway often backs up due to rush hour traffic or traffic incidents. Traffic backup is indicated on the highway by peaks in the number of cars counted every 15 seconds. Visualize the instances at which the density was more than 15 over the last 120 data points.

title('Eastbound Peaks');

The plot shows instances in the last 120 minutes when there were more than 15 cars crossing the east bound highway in a 15-second window.

Since the data is based on real traffic, it is possible that there are no peaks over the value specified in the findpeaks function. If your function does not return any peaks, experiment with the MinPeakHeight (15) or the number of data points read from ThingSpeak (120).

See Also