Advertisement
makispaiktis

Course 1 - Generate signals (sinus, square, sawtooth)

Aug 31st, 2023
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.49 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5. % 1. Sampling and signal frequency (fs, f)
  6. fs = 100;
  7. t = 0 : 1/fs : 1;
  8. f = 5;
  9.  
  10. % 2. Create a non-noisy and a noisy signal
  11. sig = sin(2*pi*f*t);
  12. plot(t, sig);
  13. noise = 0.1 * randn(size(sig));
  14. sigNoisy = sig + noise;
  15. plot(t, sigNoisy);
  16.  
  17. % 3. Square wave and sawtooth
  18. sq = square(2*pi*f*t);
  19. plot(t, sq);
  20. saw = sawtooth(2*pi*f*t);
  21. plot(t, saw);
  22. sqNoisy = sq + 0.1 * randn(size(sq));
  23. plot(t, sqNoisy);
  24. sawNoisy = saw + 0.1 * randn(size(sq));
  25. plot(t, sawNoisy);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement