{"id":1743,"date":"2016-03-11T16:52:07","date_gmt":"2016-03-11T21:52:07","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=1743"},"modified":"2019-01-02T11:18:44","modified_gmt":"2019-01-02T16:18:44","slug":"new-matlab-feature-movmax","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2016\/03\/11\/new-matlab-feature-movmax\/","title":{"rendered":"New MATLAB Analysis Feature – movmax – for ThingSpeak"},"content":{"rendered":"
My power meter at my house reports its power every few minutes. I capture that data and send it to ThingSpeak<\/a>. The value reported\u00a0is the total kilowatt-hour (kWh). I would love to see the maximum value over an hour versus randomly reported values over an hour.\u00a0With the release of MATLAB R2016a<\/a>, ThingSpeak users have access to a new suite of data analysis features. One of them is movmax<\/a><\/em> – with movmax<\/em>, I now can look at my ThingSpeak data over time and figure a moving window of maximum values. This new feature is highly customizable for your application, but I will show you how I use it.<\/p>\n My data over an hour looks like this: 803, 919, 724, 1349, 1500, 602, 549, 899, 1678, 1577<\/p>\n Using movmax<\/em>, I can have a sliding window ran over my data to pull out a maximum value from the window and use it\u00a0for visualization or further analysis.<\/p>\n The MATLAB code to process my power data is really straightforward.<\/p>\n Now, using the MATLAB Visualizations app on ThingSpeak, I can visualize the data. Here’s the before and after.<\/p>\n You can use movmax<\/em> in the MATLAB Analysis or MATLAB Visualizations apps on ThingSpeak. Sign up or sign into ThingSpeak<\/a>, select Apps<\/em>, and click “MATLAB Visualizations”. Create a new one with the blank template and use my MATLAB code. I will leave my channel of data up for you to try out. You can use channel number 97871<\/em> and my read API key\u00a07MOXB8G515OAD94Q<\/em>. The power data is stored in field1.<\/p>\n","protected":false},"excerpt":{"rendered":" My power meter at my house reports its power every few minutes. I capture that data and send it to ThingSpeak. The value reported\u00a0is the total kilowatt-hour (kWh). I would love to see the maximum… read more >><\/a><\/p>\n","protected":false},"author":148,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[209,225,226],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1743"}],"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=1743"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":2571,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/1743\/revisions\/2571"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}readChannelID = 97871;\r\nfieldID1 = 1;\r\nreadAPIKey = '7MOXB8G515OAD94Q';\r\n\r\n%% Read Data %%\r\n[data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 10, 'ReadKey', readAPIKey);\r\n\r\n%% Process Data %%\r\ndata_max = movmax(data, 4)\r\n\r\n%% Visualize Data %%\r\nplot(time, data_max);<\/pre>\n
<\/p>\n
<\/div>\n