{"id":2048,"date":"2017-04-08T22:30:59","date_gmt":"2017-04-09T02:30:59","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=2048"},"modified":"2017-04-08T22:31:47","modified_gmt":"2017-04-09T02:31:47","slug":"iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2017\/04\/08\/iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features\/","title":{"rendered":"IoT Day is the Day to Learn About Our New MATLAB Analytics Features"},"content":{"rendered":"<p>April 9th is <a href=\"http:\/\/www.iotday.org\/\">IoT Day<\/a>! We are celebrating by announcing new IoT Analytic features. All <a href=\"https:\/\/thingspeak.com\">ThingSpeak<\/a> users now have access to the new features of <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/release-notes.html\">MATLAB R2017a<\/a>. In ThingSpeak you can analyze and visualize your data using the power of MATLAB. With the latest updates you can visualize your IoT data as a\u00a0<a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/heatmap.html\">heatmap<\/a>\u00a0and analyze large sets of time-stamped data using\u00a0a tall <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/timetable.html\">timetable<\/a>.<\/p>\n<p><a href=\"https:\/\/thingspeak.com\/channels\/52682\"><img decoding=\"async\" loading=\"lazy\" width=\"560\" height=\"420\" class=\"aligncenter size-full wp-image-2052\" src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/04\/heatmap.png\" alt=\"\" \/><\/a><\/p>\n<p>In the latest update, we have added many new analytics features perfect for IoT data:<\/p>\n<ul>\n<li><strong>isoutlier<\/strong> \/ <strong>filloutliers<\/strong>: To find outliers in your data, use the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/isoutlier.html\">isoutlier<\/a> function. To replace outliers with alternative values, use the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/filloutliers.html\">filloutliers<\/a> function.<\/li>\n<li><strong>smoothdata<\/strong>:\u00a0Smoothing noisy data is now possible with the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/smoothdata.html\">smoothdata<\/a> function. For example, smoothdata(A,&#8217;movmedian&#8217;) smooths data with a moving-window median.<\/li>\n<li><strong>fillmissing<\/strong>:\u00a0Filling missing data using a moving mean or moving median option is now available with the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/fillmissing.html\">fillmissing<\/a> function.<\/li>\n<\/ul>\n<h2>Smooth Weather Data<\/h2>\n<p>At our headquarters in Natick, MA, we have a weather station sending data to ThingSpeak channel <a href=\"https:\/\/thingspeak.com\/channels\/12397\">12397<\/a>. We use ThingSpeak to collect raw temperature, humidity, wind, and rain data. We use MATLAB to analyze and visualize the data so we can use it for forecasting plant harvesting and building weather models. Learn how to build your own weather station at <a href=\"https:\/\/www.hackster.io\/hliang\/thingspeak-weather-station-data-analysis-2877b0\">Hackster.io<\/a> and learn how to analyze the weather data using MATLAB with the source code on <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/56910-thingspeak-weather-station\">File Exchange<\/a>.<\/p>\n<p><a href=\"https:\/\/www.hackster.io\/hliang\/thingspeak-weather-station-data-analysis-2877b0\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"480\" class=\"aligncenter size-full wp-image-2056\" src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/04\/ThingSpeak_weather_station.jpg\" alt=\"\" \/><\/a><\/p>\n<p>Often you want to process the raw data by removing outliers and smoothing the data. This helps if you are building a predictive model and to better visualize the data. The common IoT analytics workflow is to read in raw data, synchronize the data in time, detect and remove outlier values, smooth the data, and visualize the data. This example works on <a href=\"https:\/\/thingspeak.com\/apps\">ThingSpeak<\/a>, <a href=\"https:\/\/matlab.mathworks.com\/\">MATLAB Online<\/a>, and desktop MATLAB.<\/p>\n<h3>Read historic weather data<\/h3>\n<pre class=\"codeinput\">[weather,channelInfo] = thingSpeakRead(12397,...\r\n'DateRange',[datetime('Feb 04, 2016'),datetime('Feb 10, 2016')],...\r\n'outputFormat','table');<\/pre>\n<h3>Convert to timetable<\/h3>\n<pre class=\"codeinput\">weather = table2timetable(weather);<\/pre>\n<h3>Smooth the data<\/h3>\n<p>First, resample the timetable using the retime function so the times and data are uniformly spaced on the minute.<\/p>\n<pre class=\"codeinput\">wdata = retime(weather(:,{'Humidity','TemperatureF'}),'minutely','linear');<\/pre>\n<p>Smooth the data using a moving median and compare this to the original data. There are a number of moving statistics functions for vectors and matrices like movmean, movmedian, etc and also the smoothdata function which also works on timetables and uses the RowTimes as the sample points. Moving median is the default and other options are available.<\/p>\n<pre class=\"codeinput\">smdata = smoothdata(wdata);<\/pre>\n<h3>Visualize the original and smoothed temperature data on a plot<\/h3>\n<pre class=\"codeinput\">figure\r\nplot(wdata.Timestamps,wdata.TemperatureF,...\r\nsmdata.Timestamps,smdata.TemperatureF,'m--')\r\nlegend('Raw Data','Smooth Data')\r\nylabel('Temperature (\\circF)')\r\ntitle('Temperature Over Time')<\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"560\" height=\"420\" class=\"aligncenter size-full wp-image-2057\" src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/04\/smoothdata.png\" alt=\"Smooth Weather Data\" \/><\/p>\n<p>Have a happy <a href=\"http:\/\/www.iotday.org\/\">IoT Day<\/a> and we hope that you understand your IoT data a littler more by using MATLAB Analytics on ThingSpeak. I would like to thank\u00a0<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3968667-heather-gorr\">Heather Gorr<\/a> for helping me put together the example MATLAB code. Cheers!<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/iot\/files\/2017\/04\/heatmap.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"IoT Data heatmap\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>April 9th is IoT Day! We are celebrating by announcing new IoT Analytic features. All ThingSpeak users now have access to the new features of MATLAB R2017a. In ThingSpeak you can analyze and&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/iot\/2017\/04\/08\/iot-day-is-the-day-to-learn-about-our-new-matlab-analytics-features\/\">read more >><\/a><\/p>\n","protected":false},"author":148,"featured_media":2052,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[210,248,209,124],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2048"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/users\/148"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/comments?post=2048"}],"version-history":[{"count":13,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2048\/revisions"}],"predecessor-version":[{"id":2064,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2048\/revisions\/2064"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media\/2052"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=2048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=2048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=2048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}