Advertisement
Zidinjo

sigmu

Dec 4th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. % Ein Rechteck in einem gewissen Zeitintervall innerhalb einer Sekunde
  2. % Hier fehlen noch Kommentare
  3. %
  4. % Marvin Meier, 570113
  5. % Niklas Springhorn, 570407
  6. % 03.12.2015
  7.  
  8. close;
  9. clear all;
  10.  
  11. fa = 11025;
  12.  
  13. amp = 1;
  14. f = 1000; % khZ
  15. duration = 1.0; % s
  16. tonVec = [];
  17. pauseDuration = 1;
  18.  
  19. % Rechteck mit Frequenz 1Hz erzeugen
  20. % square = funcGeneratePeriodic(4, amp, f, 1, duration, fa, 0);
  21. sta = 0.1;
  22. sto = 0.4;
  23. start = min(sta, sto);
  24. stop = max(sta, sto);
  25.  
  26. % 1 * fa ist eine Sekunde.
  27. aSecondSquare = zeros(1,floor(fa*duration));
  28. % Wenn der Start gleich null ist, müssen wir beim ersten Wert anfangen
  29. startIndex = max(1, floor(start * fa));
  30. endIndex = floor(stop * fa);
  31.  
  32. aSecondSquare(startIndex:endIndex) = 1;
  33.  
  34.  
  35. % Der eigentliche "Square-Bereich" wäre folgender:
  36. % square = aSecondSquare((timeFrame(1)*fa):(timeFrame(2)*fa));
  37.  
  38. % TVec für x-Achse
  39. tVec = 0:1/fa:duration-1/fa;
  40.  
  41. % Umwandeln in den Frequenzbereich
  42. [specVec, phaVec] = funcRdft(aSecondSquare, length(aSecondSquare));
  43.  
  44. figure(1);
  45.  
  46. % Darstellung im Zeitbereich
  47. subplot(3, 1, 1);
  48. plot(tVec, aSecondSquare);
  49. title('Zeitbereich');
  50. xlabel('Zeit in s');
  51. ylabel('Amplitude');
  52.  
  53. % Darstellung im kompletten Frequenzbereich
  54. subplot(3, 1, 2);
  55. plot(specVec);
  56. title('Kompletter Frequenzbereich');
  57. xlabel('Frequenz in Hz');
  58. ylabel('Amplitude');
  59.  
  60. % Darstellung im Frequenzbereich (Ausschnitt)
  61. threshold = 20; % Bis zu wie viel Hertz soll angezeigt werden?
  62. tVec = [0:1:threshold];
  63. subplot(3, 1, 3);
  64. plot(tVec, specVec(1:threshold+1));
  65. title('Kompletter Frequenzbereich (Ausschnitt)');
  66. xlabel('Frequenz in Hz');
  67. ylabel('Amplitude');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement