% Q 
std_ua=1; %2std = 2V
std_ub=1;
std_i_om=0.0002;
std_i_th=1e-7;

dt=0.000125;

Rs=0.28; 
Ls=0.003465; 
Fmag= 0.1989; 
kp = 1.5;
p = 4.0;
J = 0.04;   
Bf = 0.0;  
Uc = 200.0; 
DT = 3e-6; 


StdQ=[ (dt/Ls)*std_ua + 0.005, ...
    (dt/Ls)*std_ub + 0.005,...
    0.0002,...
    1e-7];

Q= StdQ.^2

%R

istep=0.085;
R11 = (istep+istep)^2/12

%diffs
Tl=10;
th=[0 pi/2 pi];
dom = p/J*Tl*dt
dia = Fmag/Ls*dt*dom*sin(th)
dib = -Fmag/Ls*dt*dom*cos(th)
dth = dom*dt

% from om=0;
dom2= dom + kp*p*p * Fmag/J*dt* ( dib .* cos ( th +dth)- dia .* sin ( th +dth) ) + dom
dia = Fmag/Ls*dt*dom2.*sin(th+dth)
dib = -Fmag/Ls*dt*dom2.*cos(th+dth)
dth = dom2*dt
