Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.97 KB | None | 0 0
  1. function k = szeregi_Fouriera(N);
  2. printf("Program generuje szeregi Fouriera dla sygnalu piloksztaltnego.")
  3. printf("\n");
  4. s=0;
  5. licznik=0;
  6. while (1)
  7. printf("\n");
  8. N=input('Podaj dodatnia ilosc skladowych harmonicznych N = '); % Liczba skladowych harmonicznych
  9.  if N>0
  10.   Fs = 10^6;        % Czestotliwosc probkowania [Hz];
  11.   Ts = 1/Fs;        % Okres probkowania [sek];
  12.   f = 3000;         % Czestotliwosc sygnalu [Hz]; mamy 3kHz=3000Hz;
  13.   t = 0: Ts: 3*1/f; % Momenty czasu, w ktorym sygnal jest probkowany;
  14.   om = 2*pi*f;      % Omega - czestotliwosc katowa [rad/s];
  15.   %N = 50;
  16.   y = zeros(1,length(t));
  17.   for k = 1:1:N
  18.       y = y + (1/k).*sin(k*om*t);
  19.   end
  20.   y = (2/pi) * y;
  21.   plot(t,y,'linewidth',3)  % Wykres
  22.   title('Przebieg czasowy sygnalu piloksztaltnego. Czestotliwosc sygnalu 3 kHz.')
  23.   grid on
  24.   hold on
  25.   else
  26.   printf("\n");
  27.   printf('Podano niedodatnia ilosc skladowych harmonicznych. Prosze wprowadzic dane jeszcze raz.\n');
  28.  endif
  29. endwhile
  30. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement