Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1.  
  2. sigBeat = makeBeatStruct(10, 1300, 13, 0, 0, 0, 5);
  3. xx = sigBeat.xx1;
  4. tt = sigBeat.times;
  5. % Selected a 0.5 second region of the 10 second signal to ensure visibility
  6. plot(tt, xx); hold on; xlim([0, 0.5]); hold off;
  7. plotspec(xx,8000,1024); grid on
  8. sound(xx);
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. %% makeBeatStruct Function
  20. function sigBeat = makeBeatStruct(B, fc, fdelta, phic, phiDelt, startTime, endTime)
  21. % Elements of sigBeat provided by Equation 3
  22. sigBeat.Amp = B;
  23. sigBeat.fc = fc;
  24. sigBeat.phic = phic;
  25. sigBeat.fDelt = fdelta;
  26. sigBeat.phiDelt = phiDelt;
  27. sigBeat.t1 = startTime;
  28. sigBeat.t2 = endTime;
  29. % Computed elements of Equation 4
  30. sigBeat.f1 = sigBeat.fDelt + sigBeat.fc;
  31. sigBeat.f2 = sigBeat.fDelt - sigBeat.fc;
  32. sigBeat.X1 = (B/2)*exp(j*(phiDelt + sigBeat.phic));
  33. sigBeat.X2 = (B/2)*exp(j*(phiDelt - sigBeat.phic));
  34. % Creates time scale and computes function values using both eq 3 and eq 4
  35. tt = sigBeat.t1:1/8000:sigBeat.t2;
  36. % Equation 3 Signal
  37. sigBeat.xx1 = sigBeat.Amp*cos(2*pi*sigBeat.fDelt*tt + sigBeat.phiDelt).*cos(2*pi*sigBeat.fc*tt + sigBeat.phic);
  38. % Equation 4 Signal
  39. sigBeat.xx2 =(B/2)*cos(2*pi*sigBeat.f1*tt + (phiDelt + sigBeat.phic))+(B/2)*cos(2*pi*sigBeat.f2*tt + (phiDelt - sigBeat.phic));
  40. sigBeat.times = tt;
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement