close all
filename = 'charging.csv';
data= readtable(filename);

time = datetime(data.Time, 'InputFormat','HH:mm:ss.SSS');
time = time - time(1);
time(1) = [];
data([1],:) = [];


% title('\fontsize{20}Výstupné parametre pri nabíjaní 4S 2200 mAh');
xlabel('\fontsize{20}Čas [MM:SS]');
yyaxis left
plot(time,movmean(data.I_out,10), 'Color',[0 0.447 0.741], 'LineWidth',1.5);
xtickformat('mm:ss');
ax = gca;
set(gca,'XMinorTick','on','YMinorTick','on');
ylabel('\fontsize{20}Výstupný prúd [A]');
hold on
yyaxis right
plot(time, movmean(data.V_out,10), 'Color',[0.85 0.325 0.098], 'LineWidth',1.5);
ylabel('\fontsize{20}Výstupné napätie [V]');

ax = gca;
xlim([duration(0,0,0), duration(0,37,0)]);
% ylim([70, 100]);
ax.XAxis.TickValues = duration(0,0,0):duration(0,5,0):duration(0,40,0);
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = duration(0,0,0):duration(0,1,0):duration(0,40,0);
% ax.YAxis.TickValues = 15.4:0.2:16.8;
% ax.YAxis.MinorTick = 'on';
% ax.YAxis.MinorTickValues = 15.4:0.05:16.8;
grid on;
ax.XMinorGrid = 'on';
%ax.YMinorGrid = 'on';
set(gca,'XMinorTick','on','YMinorTick','on');
% set(gca,'YMinorTick',[0 0.5 1 1.5 2 2.5 3  3.5 4 4.5 5 5.5 6] );

P_in = data.V_in.*data.I_in;
P_out = data.V_out.*data.I_out;
eff = (P_out./P_in)*100;
figure(2)
yyaxis left
hold on
plot(time, movmean(eff,10), 'Color',[0 0.447 0.741], 'LineWidth',1.5);
xtickformat('mm:ss');
% title('\fontsize{20}Účinnos a teplota pri nabíjaní 4S 2200 mAh');
xlabel('\fontsize{20}Čas [MM:SS]');
ax = gca;
set(gca,'XMinorTick','on','YMinorTick','on');
ylabel('\fontsize{20}Účinnos [%]');
yyaxis right
plot(time, movmean(data.Temp,10), 'Color',[0.85 0.325 0.098], 'LineWidth',1.5);
ylabel('\fontsize{20}Teplota [°C]');

ax = gca;
xlim([duration(0,0,0), duration(0,37,0)]);
% ylim([70, 100]);
ax.XAxis.TickValues = duration(0,0,0):duration(0,5,0):duration(0,40,0);
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = duration(0,0,0):duration(0,1,0):duration(0,40,0);
% ax.YAxis.TickValues = 15.4:0.2:16.8;
% ax.YAxis.TickValues = 15.4:0.2:16.8;
% ax.YAxis.MinorTick = 'on';
% ax.YAxis.MinorTickValues = 15.4:0.05:16.8;
grid on;
ax.XMinorGrid = 'on';
%ax.YMinorGrid = 'on';
set(gca,'XMinorTick','on','YMinorTick','on');
% set(gca,'YMinorTick',[0 0.5 1 1.5 2 2.5 3  3.5 4 4.5 5 5.5 6] );

figure(3)
xlabel('\fontsize{20}Čas [MM:SS]');
% title('\fontsize{20}Vstupné parametre pri nabíjaní 4S 2200 mAh');
yyaxis left
plot(time,movmean(data.I_in,10), 'Color',[0 0.447 0.741], 'LineWidth',1.5);
xtickformat('mm:ss');
ax = gca;
set(gca,'XMinorTick','on','YMinorTick','on');
ylabel('\fontsize{20}Vstupný prúd [A]');
hold on
yyaxis right
plot(time, movmean(data.V_in,10), 'Color',[0.85 0.325 0.098], 'LineWidth',1.5);
ylabel('\fontsize{20}Vstupné napätie [V]');
ylim([9 13]);
ax = gca;
xlim([duration(0,0,0), duration(0,37,0)]);
% ylim([70, 100]);
ax.XAxis.TickValues = duration(0,0,0):duration(0,5,0):duration(0,40,0);
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = duration(0,0,0):duration(0,1,0):duration(0,40,0);
% ax.YAxis.TickValues = 15.4:0.2:16.8;
% ax.YAxis.MinorTick = 'on';
% ax.YAxis.MinorTickValues = 15.4:0.05:16.8;
grid on;
ax.XMinorGrid = 'on';
%ax.YMinorGrid = 'on';
set(gca,'XMinorTick','on','YMinorTick','on');
% set(gca,'YMinorTick',[0 0.5 1 1.5 2 2.5 3  3.5 4 4.5 5 5.5 6] );




