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

(*proklad obrazku*)
dat1=Import["dataUloha10.csv"];
vyr=Fit[dat1/.{a_,b_}:>{a,(1/b)},(t^(#))&/@Range[0,4,1],t];
pl1=Plot[(1/vyr),{t,-2,2},PlotRange->All,PlotStyle->Thick];
intdat1=Interpolation[dat1];
pl2=ListPlot[dat1,PlotStyle->{Red, PointSize[0.005]}];
Show[pl1,pl2];
pl3=Plot[(1/vyr)-intdat1[t],{t,-2,2},PlotRange->All,PlotStyle->Thick];

(*vykon na diode*)
iD[uD_]:=(10^(-7))*(Exp[19uD]-1.);
Plot[iD[u],{u,-0.1,1.},PlotStyle->Thick];
f=50.;
T=(1/f);
ω=2.*Pi*f;
u[t_]:=15*Sin[ω*t];
R=2.3;
rce[t_]:={u[t]==id*R+ud,id==iD[ud]};
sol[t_]:={id,ud}/.FindRoot[rce[t],{id,0},{ud,0}];
dats={#,sol[#]}&/@Range[0,T,(T/500)];
ListPlot[dats/.{t_,{id_,ud_}}:>{t,id}];
ListPlot[dats/.{t_,{id_,ud_}}:>{t,ud}];
intP=Interpolation[dats/.{t_,{id_,ud_}}:>{t,id*ud}];
strP=(1/T)*NIntegrate[intP[t],{t,0,T}];
Print["Pstr= ",strP," W"]

(*minimum ztrat*)

Rv1=1;
mH=0.001;
Lv1=3mH;
Rv2=0.2Rv1;
Lv2=0.2Lv1;
Lz=300mH;
Rz=100;
ω=2Pi*50;
U=230.;
eqns={((U-Uu)/(I*ω*Lv1+Rv1))==(Uu/(I*ω*Lz))+(Uu/Rz)+(Uu/(I*ω*Lv2+Rv2+(1/(I*ω*c))))};
dosUu=Solve[eqns,Uu][[1]]//Simplify;
forMin=Rv1*((Abs[((U-Uu)/(I*ω*Lv1+Rv1))])^2)+Rv2*((Abs[(Uu/(I*ω*Lv2+Rv2+(1/(I*ω*c))))])^2)/.dosUu;
FindMinimum[forMin,{c,(10^(-6))}]