• 大小: 143KB
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2024-01-30
  • 语言: Matlab
  • 标签: MATLAB  系统辨识  

资源简介

学习系统辨识课程时候的实验作业,仅供大家参考~~~

资源截图

代码片段和文件信息

clear;

sigma=input(‘白噪声标准差设定为? ‘);
r=input(‘生成数据周期数(1—3)? ‘);

%%%%%%%%%%%%%%生成a=1P=6的M序列%%%%%%%%%%%%%%%%%
M=[0 0 1 0 1 0 0];
Np=2^6-1;
for k=1:252
     if M(7)==0 
        u(k)=1;end;
     if M(7)==1  
        u(k)=-1;end;
     for i=7:-1:2
        M(i)=M(i-1);
     end
     M(1)=M(6)+M(7);
     if M(1)==2 
        M(1)=0;end;
end
u=u-mean(u);
%%%%%%%%%%%%%%%生成高斯白噪声%%%%%%%%%%%%%%%%%%%%
A=179;  xi=11;  M=2^15;
for k=1:252        
    ksai=0;
    for i=1:12
        xi=A*xi;
        xi=mod(xiM);
        ksai=ksai+(xi/M);
    end
v(k)=sigma*(ksai-6);
end

%%%%%%%%%%%%%%%%%%理论输出数据%%%%%%%%%%%%%%%%%%%%%%
k=120; T1=8.3; T2=6.2; T0=1;
K=k/(T1*T2);
E1=exp(-T0/T1);
E2=exp(-T0/T2);
x(1)=0;y(1)=0;
for k=2:252
    x(k)=E1*x(k-1)+T1*K*(1-E1)*u(k-1)+T1*K*(T1*(E1-1)+T0)*(u(k)-u(k-1))/T0;
    y(k)=E2*y(k-1)+T2*(1-E2)*x(k-1)+T2*(T2*(E2-1)+T0)*(x(k)-x(k-1))/T0;
end
z=y+v;

%%%%%%%%%%%%%%%%%%计算互相关函数%%%%%%%%%%%%%%%%%%
for k=1:Np
    R(k)=0;
for i=(Np+1):(r+1)*Np
    R(k)=R(k)+u(i-k)*z(i);
end
Rmz(k)=R(k)/(r*Np);
end
%%%%%%%%%%%%%%%%%%脉冲响应估计值%%%%%%%%%%%%%%%%%%
for k=1:Np
g(k)=(Rmz(k)-Rmz(Np-1))*Np/(Np+1);
end

%%%%%%%%%%%%%%%%%%脉冲响应理论值%%%%%%%%%%%%%%%%%%
K=120;
for k=1:Np
g0(k)=K*(exp(-k/T1)-exp(-k/T2))/(T1-T2);
end
%%%%%%%%%%%%%%%%%%脉冲响应估计误差%%%%%%%%%%%%%%%%%%%
G=g0-g;
GG=G.*G;
gg=g0.*g0;
E=sqrt(sum(GG)/sum(gg))
figure
plot(1:Npg‘r*‘)
hold on
plot(1:Npg0‘.‘)
legend(‘脉冲响应估计曲线‘‘脉冲响应理论曲线‘)

%%%%%%%%%%%%%%%%%%%%%%计算噪声方差%%%%%%%%%%%%%%%%%
a=0;
for i=1:length(v)
    a=a+v(i);
end
a=a/252;
varv=0;
for i=1:252
    varv=varv+(v(i)-a)^2;
end
varv=varv/252;
%%%%%%%%%%%%%%%%%%%计算过程输出数据方差%%%%%%%%%%%%%%%%
b=0;
for i=1:length(y)
    b=b+y(i);
end
b=b/252;
vary=0;
for i=1:252
    vary=vary+(y(i)-b)^2;
end
vary=vary/252;
%%%%%%%%%%%%%%%%%%%%计算过程信噪比%%%%%%%%%%%%%%%%%%
xinzaobi=sqrt(varv/vary)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     177583  2011-10-17 15:31  实验报告.docx

     文件       1990  2011-04-25 20:37  main.m

----------- ---------  ---------- -----  ----

               179573                    2


评论

共有 条评论