{"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":"
April 9th is IoT Day<\/a>! We are celebrating by announcing new IoT Analytic features. All ThingSpeak<\/a> users now have access to the new features of 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\u00a0heatmap<\/a>\u00a0and analyze large sets of time-stamped data using\u00a0a tall timetable<\/a>.<\/p>\n In the latest update, we have added many new analytics features perfect for IoT data:<\/p>\n At our headquarters in Natick, MA, we have a weather station sending data to ThingSpeak channel 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 Hackster.io<\/a> and learn how to analyze the weather data using MATLAB with the source code on File Exchange<\/a>.<\/p>\n 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 ThingSpeak<\/a>, MATLAB Online<\/a>, and desktop MATLAB.<\/p>\n First, resample the timetable using the retime function so the times and data are uniformly spaced on the minute.<\/p>\n 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 Have a happy 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\u00a0Heather Gorr<\/a> for helping me put together the example MATLAB code. Cheers!<\/p>\n","protected":false},"excerpt":{"rendered":" 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… 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}]}}
<\/a><\/p>\n\n
Smooth Weather Data<\/h2>\n
<\/a><\/p>\nRead historic weather data<\/h3>\n
[weather,channelInfo] = thingSpeakRead(12397,...\r\n'DateRange',[datetime('Feb 04, 2016'),datetime('Feb 10, 2016')],...\r\n'outputFormat','table');<\/pre>\nConvert to timetable<\/h3>\n
weather = table2timetable(weather);<\/pre>\n
Smooth the data<\/h3>\n
wdata = retime(weather(:,{'Humidity','TemperatureF'}),'minutely','linear');<\/pre>\nsmdata = smoothdata(wdata);<\/pre>\n
Visualize the original and smoothed temperature data on a plot<\/h3>\n
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>\n
<\/div>\n