clear;
clc;
close all;

F=csvread('F0000CH1.CSV');
H=csvread('F0000CH2.CSV');

decimala1=F(:,1);
ceo1=F(:,2);

decimala2=H(:,1);
ceo2=H(:,2);

l=length(ceo1);
sample=1e-5;


f=ceo1+decimala1;
h=ceo2+decimala2;

t=sample:sample:l*sample;

figure
plot(t,f);
xlabel('vreme [s]');
ylabel('CH1 [V]');
grid;

figure
plot(t,h);
xlabel('vreme [s]');
ylabel('CH2 [V]');
grid;

brojac=0.02/sample;
suma1=0;
suma2=0;
for i=1:brojac
    suma1=suma1+f(i)*f(i)*sample;
    suma2=suma2+h(i)*h(i)*sample;
end

efektivna1=sqrt(suma1/0.02);

disp(sprintf('*******************************************************************************'))
disp(sprintf('                      Efektivna vrednost na kanalu 1:  '))
E1=efektivna1

efektivna2=sqrt(suma2/0.02);

disp(sprintf('*******************************************************************************'))
disp(sprintf('                      Efektivna vrednost na kanalu 2:  '))
E2=efektivna2