Advertisement
szymcio93

zad3

Oct 13th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. N=100;
  2. A1=50;
  3. A2=100;
  4. A3=150;
  5. f1=50;%częstotliwosc sygnału
  6. f2=100;
  7. f3=150;
  8. fs=1000;
  9. n1=[1:N];
  10. ff=(0:N-1)*fs/N;
  11. tn=n1/fs;
  12. xs=A1*sin(2*pi*f1*tn)+A2*sin(2*pi*f2*tn)+A3*sin(2*pi*f3*tn);
  13.  
  14. for k=1:1
  15. for n=1:N
  16. A(1,n)=sqrt(1/N)*cos((pi*k/N)*(n+0.5));
  17. end
  18. end
  19. for k=2:N
  20. for n=1:N
  21. A(k,n)=sqrt(2/N)*cos(pi*k/N*(n+0.5));
  22. end
  23. end
  24.  
  25.  
  26. S=inv(A);
  27. y=A*xs';
  28. figure(1);
  29. for k=1:N
  30. plot(A(k,:),'b');
  31. plot(S(:,k),'r');
  32. pause(0.1);
  33. end
  34.  
  35. figure(2);
  36. plot(ff,abs(y(1:N)),'b');
  37.  
  38. xr=S*y;
  39. figure(3);
  40. hold on;
  41. plot(xs,'b');
  42. plot(xr,'r');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement