www.pudn.com > PMSM111.zip > Arithmetic_LS.asv, change:2011-06-15,size:990b


function Output_LS=Arithmetic_LS(x); 
% author--ljh.11.06.15 
% 输入变量: 
% x(1)--Te(t-1) 
% x(2)--w(t)-w(t-1) 
% x(3)--timesvm 
global P U K Theta I Fhi J Te H1 H2 H20 
global times now Duration lam time w1 w2 
Duration=10e-6;%采样周期,10微妙 
lam=1; 
now=x(3); 
%mmmmmmmm初始化mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm 
if now<1e-6 
    times=1e-6; 
    I=eye(2); 
    P=10^9*I; 
    Theta=zeros(1,2)'; 
    H1=x(1);                    % w(k-1) 
    H2=x(2);                    % Te(k-1)-Td(k-1) 
    %Theta=[2.4997 0.99998]'; 
%mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm 
    elseif now<times+Duration         
        U=x(1);                     % w(k) 
        H20=x(2); 
        Fhi=[H1 H2]';               % [w(k-1) Te(k-1)-Td(k-1)]' 
        K=(1/(lam+Fhi'*P*Fhi))*P*Fhi; 
        P=(I-K*Fhi')*P/lam; 
        Theta=Theta+K*(U-Fhi'*Theta); 
        H1=U;                       % 为下个周期准备 
        H2=H20; 
       times=now; 
end 
Output_LS=[Theta(1) Theta(2)];