Skip to content

Instantly share code, notes, and snippets.

@tbbooher
Created February 15, 2014 12:54
Show Gist options
  • Save tbbooher/9018958 to your computer and use it in GitHub Desktop.
Save tbbooher/9018958 to your computer and use it in GitHub Desktop.
function [P1, P2] = plot_power
P1files = {'10_1.txt', '10_2.txt'};
P2files = {'11_1.txt', '11_2.txt'};
P1 = combine(P1files, 'Meter 1');
P2 = combine(P2files, 'Meter 2');
h = figure;
subplot(2,1,1);
plot(P1);
subplot(2,1,2);
plot(P2);
end
function t = combine(fileList, n)
x = [];
for ii = 1:numel(fileList)
fid = fopen(fileList{ii}, 'r');
raw = fscanf(fid, '%g,%g', [2 inf])';
x = [x; raw];
fclose(fid);
end
for i = 1:length(x)
d{i} = datestr(datenum([1970 1 1 -5 0 x(i,1)]));
end
data = x(:,2);
data(data>7e3) = 6e3;
time_data = d';
t = timeseries(data, time_data, 'Name', n);
% X.TimeInfo.Units = 'seconds';
% X.TimeInfo.StartDate = d(1);
t.TimeInfo.Format = 'dd hh:mm';
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment