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

f=50;
T=(1/f);
τ1=2T;
τ2=1.1T;
vyr=Exp[((-t)/(τ1))]*Exp[((-t)/(τ2))]*Sin[2*Pi*f*t+0.3];
Plot[vyr,{t,0,6T},PlotRange->All];
rce=0==D[vyr,t];
extr[k_]:=t/.FindRoot[rce,{t,k*0.5T}];
extr/@Range[6]
%-%[[1]]

FindRoot[rce,{t,1*0.5T}]
FindRoot[rce,{t,2*0.5T}]
FindRoot[rce,{t,3*0.5T}]
FindRoot[rce,{t,4*0.5T}]
FindRoot[rce,{t,5*0.5T}]
FindRoot[rce,{t,6*0.5T}]

Quiet@Remove["Global`*"];
proud[u_]:=(10^(-27))*(u^19.2);
datsVaristor=Table[{u,proud[u]},{u,18,30}];
Export["datsVaristor.csv",datsVaristor]

SetDirectory[NotebookDirectory[]];

FileNames[]

datVar

datVar=Import["datsVaristor.csv"];
fit=FindFit[datVar,k1*(u^k2),{k1,k2},u,MaxIterations->1000]
proklad=k1*(u^k2)/.fit;
Show[Plot[proklad,{u,18,30}],ListPlot[datVar,PlotStyle->{Red,PointSize[0.02]}],PlotRange->All];

proklad

proudVar[u_]=proklad;
uz[t_]:=1000/;t<0.01;
uz[t_]:=0/;t≥0.01;

c=10000*(10^(-6));
R=1;
rce={i[t]==((uz[t]-u1[t])/R),i[t]==proudVar[u1[t]]+c*u1'[t],u1[0]==0};
res=NDSolve[rce,{u1,i},{t,0,0.01},StartingStepSize->(10^(-12)),MaxStepSize->(10^(-3))]
Plot[u1[t]/.res,{t,0,0.010},PlotRange->All]

rce={((uz[t]-u1[t])/R)==proudVar[u1[t]]+c*u1'[t],u1[0]==0};
res=NDSolve[rce,{u1},{t,0,0.01},StartingStepSize->(10^(-12)),MaxStepSize->(10^(-3))]
Plot[u1[t]/.res,{t,0,0.01},PlotRange->All]

f=50;
T=(1/f);
ω=2.*Pi*f;
gon[t_]:=(((0.5+Sin[ω*t+0.2]+0.3*((Cos[ω*t])^3)))^5);
Plot[gon[t],{t,0,2T}];
Print["DC slozka= ",(1/T)NIntegrate[gon[t],{t,0,T}]]

a3=(2/T)NIntegrate[gon[t]*Cos[3*ω*t],{t,0,T}];
b3=(2/T)NIntegrate[gon[t]*Sin[3*ω*t],{t,0,T}];
Print["A3= ",(Sqrt[(a3^2)+(b3^2)])]