声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1030|回复: 0

[综合] 求达人,在处理处理传递函数仿真时,出现了问题

[复制链接]
发表于 2012-6-3 15:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
最近  我想做一块关于给定某输入, 以及传递函数的基础上,  计算出结构的响应情况,  我想知道我的程序错误出在哪里?  主要是模拟两个谐频正弦信号x1,x2,再定义两个传递函数H1,H2,然后分别计算a=x1+x2*H1,  b=x2+x1*H2  本人很着急,求达人
  1. clc
  2. clear

  3. fs=200;

  4. t=0:1/fs:1;
  5. N=length(t);
  6. x1=6*sin(2*pi*10*t)+5*sin(2*pi*20*t)+4*sin(2*pi*30*t)+3*sin(2*pi*40*t)+2*sin(2*pi*50*t)+sin(2*pi*60*t);
  7. x2=6*sin(2*pi*15*t)+5*sin(2*pi*30*t)+4*sin(2*pi*45*t)+3*sin(2*pi*60*t)+2*sin(2*pi*75*t)+sin(2*pi*90*t);

  8. % x1=sin(2*pi*10*t)+sin(2*pi*20*t)+sin(2*pi*30*t)+sin(2*pi*40*t)+sin(2*pi*50*t)+sin(2*pi*60*t);
  9. % x2=sin(2*pi*15*t)+sin(2*pi*30*t)+sin(2*pi*45*t)+sin(2*pi*60*t)+sin(2*pi*75*t)+sin(2*pi*90*t);

  10. figure
  11. plot(t,x1)
  12. hold on
  13. plot(t,x2,'r')

  14. X1=fft(x1)/N;X2=fft(x2)/N;
  15. f=(1:N)*fs/N;
  16. figure
  17. plot(f(1:N/2),abs(X1(1:N/2))*2)
  18. hold on
  19. plot(f(1:N/2),abs(X2(1:N/2))*2,'r')

  20. H1=sqrt(1./(300-f.^2).^2+(40.*f).^2).*exp(-j*atan(40.*f./(300-f.^2)));
  21. H2=sqrt(1./(900-f.^2).^2+(75.*f).^2).*exp(-j*atan(75.*f./(900-f.^2)));

  22. S1=X2.*conj(X2).*H1./conj(X2);
  23. for i=1:fix(N/2)
  24.     S1(1,fix(N/2)+i)=0;
  25. end
  26. S2=X1.*conj(X1).*H2./conj(X1);
  27. for i=1:fix(N/2)
  28.     S2(1,fix(N/2)+i)=0;
  29. end
  30. AA=2*X1+S1;
  31. BB=2*X2+S2;


  32. % AA=X1+X2.*H1;
  33. % BB=X2+X1.*H2;

  34. ifftAA=ifft(AA);
  35. a=real(ifftAA);  
  36. a=a+randn(1,N);
  37. ifftBB=ifft(BB);
  38. b=real(ifftBB);  
  39. b=b+randn(1,N);


  40. figure
  41. plot(t,a)
  42. hold on
  43. plot(t,b,'r')

  44. AAA=abs(fft(a))*2/N;BBB=abs(fft(b))*2/N;
  45. figure
  46. plot(f(1:N/2),AAA(1:N/2))
  47. hold on
  48. plot(f(1:N/2),BBB(1:N/2),'r')
复制代码
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-9 22:27 , Processed in 0.139939 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表