function [ z ] = es4( )
%ES4 Valutazione parametri corrente Ic
%Caricamento dati
prn=load('s00.prn');
t=prn(:,1);
vr=prn(:,4);
dati=load('data.txt');
R1=dati(2);
%Calcolo dei parametri richiesti
VRmax=max(vr);
VRmin=min(vr);
ICmax=VRmax/R1;
ICmin=VRmin/R1;
ICpp=ICmax-ICmin;
ICrapp=ICmax/ICmin;
trigger=find(t==0);
estremi=find(vr==vr(trigger));
plot(t(estremi),vr(estremi),'ro');
hold on;
plot(t,vr);
xlabel('t [s]');
ylabel('Ic [mA]');
title('Determinazione del periodo');
T=(t(estremi(2))-t(estremi(1)))*1000;
F=inv(T);
%Calcolo dell'incertezza con HP54600B
disp('Misure con HP54600B:');
RFS=500;
R1=R1*1000;
G=0.2;
P=-0.55;
Kt=0.2;
U=zeros(4,1);
Q=G/64;
U(1)=1.9/100;
U(2)=2.56*Q+0.5*abs(P)/100;
U(4)=Q/2;
incVRmax=incDir(U,VRmax);
incVRmax=incVRmax/abs(VRmax);
incVRmin=incDir(U,VRmin);
incVRmin=incVRmin/abs(VRmin);
U=zeros(4,1);
U(1)=0.06/100;
U(3)=2*RFS/50000;
incR1=incDir(U,R1);
incR1=incR1/abs(R1);
incRelICmax=incVRmax+incR1;
incICmax=incRelICmax*abs(ICmax);
stringa=['ICmax = ' num2str(ICmax,'%0.2f') ' ' num2str(incICmax,'%0.2f') ' mA'];
disp(stringa);
incRelICmin=incVRmin+incR1;
incICmin=incRelICmin*abs(ICmin);
stringa=['ICmin = ' num2str(ICmin,'%0.2f') ' ' num2str(incICmin,'%0.2f') ' mA'];
disp(stringa);
incICpp=incICmax+incICmin;
stringa=['ICpp = ' num2str(ICpp,'%0.2f') ' ' num2str(incICpp,'%0.2f') ' mA'];
disp(stringa);
incICrapp=incRelICmax+incRelICmin;
incICrapp=incICrapp*abs(ICrapp);
stringa=['ICrapp = ' num2str(ICrapp,'%0.1f') ' ' num2str(incICrapp,'%0.1f') ' mA'];
disp(stringa);
U=zeros(4,1);
U(1)=0.01/100;
U(3)=100e-9;
Tsa=10*Kt/500;
U(4)=Tsa/2;
incT=incDiff(U,T);
stringa=['T = ' num2str(T,'%0.3f') ' ' num2str(incT,'%0.3f') ' ms'];
disp(stringa);
incF=incT/T2;
stringa=['f = ' num2str(F,'%0.3f') ' ' num2str(incF,'%0.3f') ' kHz'];
disp(stringa);
%Calcolo dell'incertezza con NB-A2000
disp(' ');
disp('Misure con NB-A2000:');
U=zeros(4,1);
Q=8*G/212;
U(1)=Q;
U(2)=0.2*Q;
U(3)=Q;
U(4)=Q/2;
incVRmax=incDir(U,VRmax);
incVRmax=incVRmax/abs(VRmax);
incVRmin=incDir(U,VRmin);
incVRmin=incVRmin/abs(VRmin);
U=zeros(4,1);
U(1)=0.06/100;
U(3)=2*RFS/50000;
incR1=incDir(U,R1);
incR1=incR1/abs(R1);
incRelICmax=incVRmax+incR1;
incICmax=incRelICmax*abs(ICmax);
stringa=['ICmax = ' num2str(ICmax,'%0.2f') ' ' num2str(incICmax,'%0.2f') ' mA'];
disp(stringa);
incRelICmin=incVRmin+incR1;
incICmin=incRelICmin*abs(ICmin);
stringa=['ICmin = ' num2str(ICmin,'%0.2f') ' ' num2str(incICmin,'%0.2f') ' mA'];
disp(stringa);
incICpp=incICmax+incICmin;
stringa=['ICpp = ' num2str(ICpp,'%0.2f') ' ' num2str(incICpp,'%0.2f') ' mA'];
disp(stringa);
incICrapp=incRelICmax+incRelICmin;
incICrapp=incICrapp*abs(ICrapp);
stringa=['ICrapp = ' num2str(ICrapp,'%0.2f') ' ' num2str(incICrapp,'%0.2f') ' mA'];
disp(stringa);
U=zeros(4,1);
U(1)=0.01/100;
Tsa=10*Kt/500;
U(4)=Tsa/2;
incT=incDiff(U,T);
stringa=['T = ' num2str(T,'%0.3f') ' ' num2str(incT,'%0.3f') ' ms'];
disp(stringa);
incF=incT/T2;
stringa=['f = ' num2str(F,'%0.3f') ' ' num2str(incF,'%0.3f') ' kHz'];
disp(stringa);
pause;
close;