Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. Fs = 44100; % Sampling frequency in Hz
  2. T = 1; % Total duration of the signal in seconds
  3. f = 120; % Frequency of the oscillator
  4. t = 0:(1./Fs):(T - (1./Fs)); % Time vector
  5. p = 2.0 .* pi .* t; %Phase vector
  6. y = sin(f.*p);
  7.  
  8. Fs = 44100; % Sampling frequency in Hz
  9. T = 1; % Total duration of the signal in seconds
  10. f0 = 1; % Start chirp at
  11. f1 = 120; % end chirp at (Better keep f1>f0)
  12. t = 0:(1./Fs):(T - (1./Fs)); % Time vector
  13. p = 2.0 .* pi .* t; %Phase vector
  14. y = sin(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2));
  15.  
  16. s = diff(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2)); % Get the first derivative of phase to find the **rate of change**.
  17.  
  18. r = f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2); % The phase as above.
  19. z = r(end) + cumsum(ones(1,T.*Fs).*0.017097); % A running sum of duration T.*Fs (samples).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement