I have the matlab code below but it sometimes fails because of duplicated time-stamps in the data. (this causes 'bar' to fail with 'XData must be unique' error).
Wondering how to get a unique set of timestamps then rejoin them to the values (I dont particularly care which of the duplicated values gets matched). My newbie attempts to use the 'unique' function do not work because the row as a whole is considered unique even when the timestamps are the same.
02/10/2016 01:30 | -436.43 |
02/10/2016 01:30 | -390.61 |
02/10/2016 01:35 | -390.68 |
02/10/2016 01:35 | -390.6 |
% Draw a bar graph of Interconnector power
% red for positive, blue for negative
power = thingSpeakRead(150393,'OutputFormat','Table','NumDays',3);
pos=unique(power(power.Interconnect > 0,[1,4]));
neg=unique(power(power.Interconnect <= 0,[1,4]))
figure('position', [0, 0, 1200, 700])
bar(datenum(neg.Timestamps),neg.Interconnect,'r','BarWidth',1,'EdgeColor','r')
hold on
bar(datenum(pos.Timestamps),pos.Interconnect,'b','BarWidth',1,'EdgeColor','b')
hold off
datetick('x','ddd dd/mm')
title 'South Australian Interconnector Load'
ylabel 'Net Power (MW)'
legend('Buying Power','Selling Power','Location','northwest')
axis 'tight'