Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];

Rtry=100;
Ctry=5*(10^(-6));
Y[f_]:=(1/Rtry)+I*2*Pi*Ctry*f;
ParametricPlot[{Re[(1/(Y[f]))],Im[(1/(Y[f]))]},{f,0,(10^5)},PlotRange->All,PlotPoints->300,PlotStyle->Thick];

dats=Import["data.xls"][[1]];
ListPlot[dats/.{f_,R_,X_}:>{R,X}];

bod[f_]:={f,Re[(1/(Y[f]))],Im[(1/(Y[f]))]}//N;
fmin=10;
fmax=10000;
nfrekvenci=100;
q=qpom/.FindRoot[fmin*(qpom^(nfrekvenci-1))==fmax,{qpom,1.1}];
frekvence=fmin*(q^(#-1))&/@Range[nfrekvenci];
body=bod/@frekvence;

Z[f_]:=((R*(1/(I*2.*Pi*f*c)))/(R+(1/(I*2.*Pi*f*c))));
odchylka[{f_,R_,X_}]:=Abs[R+I*X-Z[f]];
proFindMin=Plus@@(odchylka/@body);
FindMinimum[proFindMin,{c,(10^(-6))},{R,10},Method->"PrincipalAxis"]

dats=Import["data.xls"][[1]];
pl1=ListPlot[dats/.{f_,R_,X_}:>{R,X},PlotStyle->{Red,PointSize[0.015]}];proFindMin=Plus@@(odchylka/@dats);
resmin=FindMinimum[proFindMin,{c,(10^(-6))},{R,10},Method->"PrincipalAxis"][[2]];
Y[f_]:=(1/Rtry)+I*2*Pi*Ctry*f;
pl2=ParametricPlot[{Re[Z[f]/.resmin],Im[Z[f]/.resmin]},{f,0,(10^5)},PlotRange->All,PlotPoints->300,PlotStyle->Thick];
Show[pl1,pl2]

f=50;
T=(1/f);
uz[t_]:=10*Sin[2*Pi*f*t+0.564]+3*Sin[2*Pi*3*f*t+0.81];
Plot[uz[t],{t,0,2T}];
ClearAll[proud];
proud[t_]:=((uz[t])/Rtry)+Ctry*uz'[t];
Plot[proud[t],{t,0,2T},PlotPoints->3000]//Timing;
ndat=100;
dataScilo={#,uz[#],proud[#]}&/@Range[0,T,(T/(ndat-1.))];

(*Take[#,2]&/@dataScilo;
Drop[#,-1]&/@dataScilo;
Transpose@Drop[Transpose[dataScilo],-1]*)

intuz=Interpolation[dataScilo/.{t_,u_,i_}:>{t,u}];
intproud=Interpolation[dataScilo/.{t_,u_,i_}:>{t,i}];
dataproFit={intuz[#],intuz'[#],intproud[#]}&/@Range[0,T,(T/(ndat-1.))];
Fit[dataproFit,{u,deru},{u,deru}]