Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function one_2()
- clc;
- clear;
- global Fs;
- Fs = 1000;
- samples = 200;
- t = 0:1/Fs:1/2*samples*1/Fs;
- x_n = cos(125.*pi.*t).*cos(325.*pi.*t)
- L = 200;
- plot_signal(x_n, "Amplitude", "Samples", "Sampled signal at f_s = 1 KHz sampling rate", false, NaN, 1);
- t = 0:1/Fs:samples*1/Fs;
- x_n = cos(125.*pi.*t).*cos(325.*pi.*t)
- plot_spectrum(x_n, L, 2);
- plot_spectrum(x_n, L/2, 3);
- end
- function plot_signal(x, ylab, xlab, tl, isFreq, N, p)
- global Fs;
- subplot(3,1,p);
- if (isFreq == true)
- stem((-N/2:N/2-1)*Fs/N, x, 'b.-', 'LineWidth', 2, 'MarkerSize', 15)
- else
- stem(0:numel(x)-1, x, 'r.-', 'LineWidth', 2, 'MarkerSize', 15)
- end
- title(tl);
- xlabel(xlab);
- ylabel(ylab);
- grid on;
- end
- function plot_spectrum(x, N, p)
- fx = fftshift(fft(x, N));
- plot_signal(abs(fx), "|X(f)|", "Frequency (Hz)", "Spectrum of the x(n) signal, N = " + N, true, N, p);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement