华南理工大学信号与系统实验基于Matlab的信号处理实例

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

第2讲基于Matlab的信号处理实例实验内容(1)(1)读取给定的3D加速度信号文件,绘出信号波形;程序源代码:functionsy2fid=fopen('run100m_TROUSERSPOCKET_1_陈佳_1.txt','r');a=fscanf(fid,'%d,%d,%d\n');fclose(fid);len=length(a)/3;k=1;fori=1:lenx(i)=a(k);y(i)=a(k+1);z(i)=a(k+2);k=k+3;endsubplot(3,1,1);plot(x(1:700),'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('x(i)');%标示名称subplot(3,1,2);plot(y(300:700),'m','LineWidth',3)gridon;%标示格子xlabel('n'),ylabel('y');%标示坐标legend('y(i)');%标示名称subplot(3,1,3);plot(z(300:700),'b','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('z');%标示坐标legend('z(i)');%标示名称执行结果如下所示:0100200300400500600700050100150200nxx(i)05010015020025030035040045050100150200250nyy(i)0501001502002503003504004500100200300nzz(i)(2)将读出的3D加速度信号分解为偶序列及奇序列,分别绘出波形;绘出偶序列及奇序列的和信号、差信号及积信号的波形;a.分解为偶序列及奇序列,分别绘出波形:程序源代码:functionsy2oefid=fopen('run100m_TROUSERSPOCKET_1_陈佳_1.txt','r');a=fscanf(fid,'%d,%d,%d\n');fclose(fid);len=length(a)/3;k=1;fori=1:lenx(i)=a(k);y(i)=a(k+1);z(i)=a(k+2);k=k+3;endx0=[zeros(1,len-1),x];%x前面补0x1=fliplr(x0);%x1即是反转的x0ex=(x1+x0)/2;%x的偶部ox=-(x1-x0)/2;%x的奇部y0=[zeros(1,len-1),y];y1=fliplr(y0);ey=(y1+y0)/2;oy=-(y1-y0)/2;z0=[zeros(1,len-1),z];z1=fliplr(z0);ez=(z1+z0)/2;oz=-(z1-z0)/2;subplot(3,2,1);plot([-len+1:len-1],ex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('ex(i)');%标示名称subplot(3,2,3);plot([-len+1:len-1],ey,'m','LineWidth',3)gridon;%标示格子xlabel('n'),ylabel('y');%标示坐标legend('ey(i)');%标示名称subplot(3,2,5);plot([-len+1:len-1],ez,'b','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('z');%标示坐标legend('ez(i)');%标示名称subplot(3,2,2);plot([-len+1:len-1],ox,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('ox(i)');%标示名称subplot(3,2,4);plot([-len+1:len-1],oy,'m','LineWidth',3)gridon;%标示格子xlabel('n'),ylabel('y');%标示坐标legend('oy(i)');%标示名称subplot(3,2,6);plot([-len+1:len-1],oz,'b','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('z');%标示坐标legend('oz(i)');%标示名称sumoex=ex+ox;sumoey=ey+oy;sumoez=ez+oz;执行结果如下所示:-4000-3000-2000-100001000200030004000050100150nxex(i)-4000-3000-2000-100001000200030004000050100150200nyey(i)-4000-3000-2000-100001000200030004000050100150nzez(i)-4000-3000-2000-100001000200030004000-100-50050100nxox(i)-4000-3000-2000-100001000200030004000-200-1000100200nyoy(i)-4000-3000-2000-100001000200030004000-200-1000100200nzoz(i)b.绘出偶序列及奇序列的和信号的波形:程序源代码:functionsumoefid=fopen('run100m_TROUSERSPOCKET_1_陈佳_1.txt','r');a=fscanf(fid,'%d,%d,%d\n');fclose(fid);len=length(a)/3;k=1;fori=1:lenx(i)=a(k);y(i)=a(k+1);z(i)=a(k+2);k=k+3;endx0=[zeros(1,len-1),x];%x前面补0x1=fliplr(x0);%x1即是反转的x0ex=(x1+x0)/2;%x的偶部ox=-(x1-x0)/2;%x的奇部y0=[zeros(1,len-1),y];y1=fliplr(y0);ey=(y1+y0)/2;oy=-(y1-y0)/2;z0=[zeros(1,len-1),z];z1=fliplr(z0);ez=(z1+z0)/2;oz=-(z1-z0)/2;sumoex=ex+ox;sumoey=ey+oy;sumoez=ez+oz;subplot(3,1,1);plot([-len+1:len-1],sumoex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('sumoex');%标示名称subplot(3,1,2);plot([-len+1:len-1],sumoex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('sumoey');%标示名称subplot(3,1,3);plot([-len+1:len-1],sumoex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('sumoez');%标示名称执行结果如下所示:-4000-3000-2000-1000010002000300040000100200nxsumoex-4000-3000-2000-1000010002000300040000100200nxsumoey-4000-3000-2000-1000010002000300040000100200nxsumoezc..绘出偶序列及奇序列的差信号的波形程序源代码:functionchoefid=fopen('run100m_TROUSERSPOCKET_1_陈佳_1.txt','r');a=fscanf(fid,'%d,%d,%d\n');fclose(fid);len=length(a)/3;k=1;fori=1:lenx(i)=a(k);y(i)=a(k+1);z(i)=a(k+2);k=k+3;endx0=[zeros(1,len-1),x];%x前面补0x1=fliplr(x0);%x1即是反转的x0ex=(x1+x0)/2;%x的偶部ox=-(x1-x0)/2;%x的奇部y0=[zeros(1,len-1),y];y1=fliplr(y0);ey=(y1+y0)/2;oy=-(y1-y0)/2;z0=[zeros(1,len-1),z];z1=fliplr(z0);ez=(z1+z0)/2;oz=-(z1-z0)/2;choex=ex-ox;choey=ey-oy;choez=ez-oz;subplot(3,1,1);plot([-len+1:len-1],choex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('choex');%标示名称subplot(3,1,2);plot([-len+1:len-1],choex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('choey');%标示名称subplot(3,1,3);plot([-len+1:len-1],choex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('choez');%标示名称执行结果如下所示:-4000-3000-2000-1000010002000300040000100200nx-4000-3000-2000-1000010002000300040000100200nx-4000-3000-2000-1000010002000300040000100200nxchoexchoeychoezd.绘出偶序列及奇序列的积信号的波形程序源代码:functionmuloefid=fopen('run100m_TROUSERSPOCKET_1_陈佳_1.txt','r');a=fscanf(fid,'%d,%d,%d\n');fclose(fid);len=length(a)/3;k=1;fori=1:lenx(i)=a(k);y(i)=a(k+1);z(i)=a(k+2);k=k+3;endx0=[zeros(1,len-1),x];%x前面补0x1=fliplr(x0);%x1即是反转的x0ex=(x1+x0)/2;%x的偶部ox=-(x1-x0)/2;%x的奇部y0=[zeros(1,len-1),y];y1=fliplr(y0);ey=(y1+y0)/2;oy=-(y1-y0)/2;z0=[zeros(1,len-1),z];z1=fliplr(z0);ez=(z1+z0)/2;oz=-(z1-z0)/2;muloex=ex.*ox;muloey=ey.*oy;muloez=ez.*oz;subplot(3,1,1);plot([-len+1:len-1],muloex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('x');%标示坐标legend('muloex');%标示名称subplot(3,1,2);plot([-len+1:len-1],muloex,'g','LineWidth',3);gridon;%标示格子xlabel('n'),ylabel('y');%标示坐标legend('muloey');%标示名称subplot(3,1,3);plot([-len+1:len-1],muloex,'g','LineWid

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功