Advertisement
Shafayat__

Untitled

Nov 4th, 2023
1,228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.69 KB | None | 0 0
  1. Fs = 20;
  2. t = 0:10/Fs:150;
  3. m = sin(t);
  4. figure(1);
  5. subplot(3,1,1);
  6. plot(t,m);
  7. title('Sine wave');
  8. k=0;
  9. for i=1:2:1000
  10.     if(i==1)
  11.         y = sin(i*t);
  12.     else
  13.         y = sin(i*t)/i;
  14.     end
  15.     k = k+y;
  16. end
  17. figure(1);
  18. subplot(3,1,2);
  19. plot(t,k);
  20. title('Square wave');
  21. h = fft(k);
  22. figure(1);
  23. subplot(3,1,3);
  24. plot(t,h);
  25. title('Fourier Transform');
  26. figure(2);
  27. subplot(3,1,1);
  28. plot(t,m);
  29. title('Sine wave');
  30. h=0;
  31. for i=1:1:1000
  32.     if(i==1)
  33.         y = sin(i*t);
  34.     else
  35.         y = sin(i*t)/i;
  36.     end
  37.     h = h+y;
  38. end
  39. figure(2);
  40. subplot(3,1,2);
  41. plot(t,h);
  42. title('Triangular wave');
  43. l = fft(h);
  44. figure(2);
  45. subplot(3,1,3);
  46. plot(t,l);
  47. title('Fourier Transform');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement