Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. clear all
  2. fs=1000 % sample frequency 1000hz
  3. nDFT=128 %128 point sample
  4. t = 0:1/fs:(nDFT)*(1/fs)
  5. x = 3*sin(80*pi*t) + sin(160*pi*t)
  6. subplot(2,1,1)
  7. stem(t,x,'.')
  8. xlabel('t')
  9. ylabel('x(t)')
  10. y=fft(x)
  11. y=fftshift(y)
  12. f=-fs/2:fs/nDFT:fs/2
  13. subplot(2,1,2)
  14. stem(f,abs(y),'.')
  15. xlabel('freq')
  16. saveas(gcf,'ex1.png')
  17. sampled_signal = fopen('sampled_signal.bin','w')
  18. fwrite(sampled_signal,x,'double')
  19. fclose(sampled_signal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement