y=load('C:\Users\Administrator\Desktop\ceshi.txt');
Y1=y;%%读取数据文件前1024个数据
N1=max(size(Y1));
N11=N1/32;
M11=32;
for i=1:N11
for j=1:M11
D1(i,j)=Y1(M11*i+j-M11);%%将一维数组转化为二维矩阵
end
end;
[U,S,V]=svd(D1);%%对构成的矩阵进行奇异值分解
for i=1:2 %%选取合适的奇异值进行信号重构
S(i,i)=0;
end;
for i=12:32
S(i,i)=0;
end;
A=U*S*V';
for i=1:N11
for j=1:M11
D2(M11*i+j-M11)=A(i,j);%%将二维矩阵转化为一维数组
end
end;
xinhao=D2(1:10016)'/8;%%将文件5121中前1024个数据赋给xinhao
m=1:10016;
subplot(211);plot(y);
subplot(212);
plot(m,xinhao,'b');%%以m为横坐标,xinhao为纵坐标,蓝色线条绘图
set(gcf,'color','w');%%将绘图背景定为白色
xlabel('采样时间t(s)','FontSize',10);
ylabel('幅值','FontSize',10);
title('处理后的信号时域图','FontSize',11);