function LSI_rec
clear;
clc;
%本实验直接给定如下样本作为测试
m=20;n=12;
x=[1,3,5,7,9,8,7.5,7,6.5,6,5.5,5,4.5,4,3.5,3,2.5,2,1,2];
h=[6.2,5.4,3.2,1.8,4.2,2,5.5,7.4,0,2.3,4.8,6.6];
%也可利用以下程序窗口输入信号x和假定的理想系统h
% m=input('input the length of input sign x:');
% for i=1:m
% x(i)=input(strcat('input x(',int2str(i-1),'):'));
% end
% n=input('input the length of your system h:');
% for i=1:n
% h(i)=input(strcat('input h(',int2str(i-1),'):'));
% end
u=randn(1,m); %设置白噪声u均值值为0,功率为1
x
s=x+u %加入均值白噪声u
y=conv(s,h); %输出信号y为
%系统辨识处理
rs=xcorr(s); %输入信号自相关
ry=xcorr(y); %输出信号自相关
rsy=xcorr(s,y); %输入信号与输出信号互相关
for i=1:n/2+m-1 %对结果进行排序
t=rsy(i);
rsy(i)=rsy(n+2*m-1-i);
rsy(n+2*m-1-i)=t;
end
[hout,r]=deconv(rsy,rs); %卷积反变换
hout %hout为系统辨识后的系统
%作图部分
subplot(221)
stem(h(1:n));
title('原系统h(n)');
subplot(222)
stem(hout(1:n));
title('辨识系统hout(n)');
subplot(223)
stem(h(1:n)-hout(1:n));
title('h(n)-hout(n)');