Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = 2; %Амплитуда
- T = 6; %Период
- tau = 5; %Длительность сигнала
- N = 10; %Число ненулевых гармоник
- t = -T:0.1 :T;% вектор моментов времени
- subpl_row = 6;
- subpl_colums = 3;
- Fs = 100;
- L = 150;
- %Последовательность прямоугольных импульсов
- q = T/tau;
- sum = A/q;
- for k = 1:N
- figure(1)
- subplot(subpl_row, subpl_colums, k);
- S = (2*A/(pi*k))*sin(pi*k/q)*cos(((2*pi*k)/T)*t);
- sum = sum + S;
- plot(t, sum);
- figure(2)
- subplot(subpl_row, subpl_colums, k)
- Y = fft(sum);
- P2 = abs(Y/L);
- P1 = P2(1:L/2+1);
- P1(2:end-1) = 2*P1(2:end-1);
- f = Fs*(0:(L/2))/L;
- plot(f,P1)
- title('Spectrum of S(t)')
- xlabel('f (Hz)')
- ylabel('|P1(f)|')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement