August 25, 2015
I'm posting energy measurements to a channel feed that are not periodic, I mean, one hour there may be 10 values, but the next one there may be 50 or 100. The problem comes when I want to calculate daily totals, because something like this:
returns meaningless values. The reason is that sum simply adds all the values inside each day, and so days with a lot of measurements have higher values than days with fewer.
Is there's some way to calculate a sum taking into account the "distance" between measurements? Graphically speaking, I would need the area under the line chart, not just the sum of the values.
August 22, 2015
I have a similar channel. You can do this in a MATLAB Analysis function:
% Get the data
[data,ts] = thingSpeakRead(32188,'NumMinutes',60);
% Calculate the number of minutes for each value (the weight)
weights = minutes(diff(ts));
% Discard the last data point (because you don't know its weight)
data(end) = ;
% Need to use "dot product" operator (.*), since MATLAB default is
% "cross product" operator.
sum(data .* weights)
Most Users Ever Online: 166
Currently Browsing this Page:
Guest Posters: 1
Newest Members:faaramin, swarnak32, SaiHarish.M, vikas, abhisheksharma, khoshghadam
Moderators: cstapels: 460
Administrators: Hans: 405, lee: 457