Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function k = szeregi_Fouriera(N);
- printf("Program generuje szeregi Fouriera dla sygnalu piloksztaltnego.")
- printf("\n");
- s=0;
- licznik=0;
- while (1)
- printf("\n");
- N=input('Podaj dodatnia ilosc skladowych harmonicznych N = '); % Liczba skladowych harmonicznych
- if N>0
- Fs = 10^6; % Czestotliwosc probkowania [Hz];
- Ts = 1/Fs; % Okres probkowania [sek];
- f = 3000; % Czestotliwosc sygnalu [Hz]; mamy 3kHz=3000Hz;
- t = 0: Ts: 3*1/f; % Momenty czasu, w ktorym sygnal jest probkowany;
- om = 2*pi*f; % Omega - czestotliwosc katowa [rad/s];
- %N = 50;
- y = zeros(1,length(t));
- for k = 1:1:N
- y = y + (1/k).*sin(k*om*t);
- end
- y = (2/pi) * y;
- plot(t,y,'linewidth',3) % Wykres
- title('Przebieg czasowy sygnalu piloksztaltnego. Czestotliwosc sygnalu 3 kHz.')
- grid on
- hold on
- else
- printf("\n");
- printf('Podano niedodatnia ilosc skladowych harmonicznych. Prosze wprowadzic dane jeszcze raz.\n');
- endif
- endwhile
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement