This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % The noise signal (without phase attenuation) | |
| N = randn(1,length(y)); | |
| % The noisey recieved signal | |
| yN = y+N; | |
| figure | |
| subplot(3,1,1),plot(y) | |
| title('Noiseless Recieved Signal') | |
| ylim([-2,2]) | |
| subplot(3,1,2),plot(N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % The noiseless recieved signal | |
| y = [zeros(1,100),ones(1,56),zeros(1,100)]; | |
| % The noise signal (without phase attenuation) | |
| N = .1*randn(1,length(y)); | |
| % The noisey recieved signal | |
| yN = y+N; | |
| figure | |
| subplot(3,1,1),plot(y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f_pad = f; | |
| g_pad = [g, zeros(1,length(f)-length(g))]; | |
| f_conv_g = ifft(fft(f_pad).*fft(g_pad)); | |
| % Convolution of f and g using FFT | |
| figure, stem(f_conv_g,'filled') | |
| xlim([-1,length(f_conv_g)+1]) | |
| ylim([-20,50]) | |
| title('Circular Convolution of f and g via FFT') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % The convolution is calculated as shown in this figure | |
| f_pad = f; | |
| g_pad = [g, zeros(1,length(f)-length(g))]; | |
| g_pad = circshift(fliplr(g_pad)',1)'; | |
| MF = zeros(1,length(f_pad)); | |
| figure('Position',[100 100 850 600]) | |
| v = VideoWriter('test.avi','Uncompressed AVI'); | |
| v.FrameRate = 1; | |
| open(v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % The f and g signals | |
| f = [1,-1,4,8]; | |
| g = [2,1,5]; | |
| % Convolution of f and g | |
| f_conv_g = conv(f,g); | |
| figure, stem(f_conv_g,'filled') | |
| xlim([-1,length(f_conv_g)+1]) | |
| ylim([-20,50]) | |
| title('Convolution of f and g') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Define parameters | |
| Fs = 16; % Sampling Frequency | |
| Ts = 1/Fs; % Sampling Period | |
| N = 64; % Total Number of Samples | |
| n = 0:N-1; % Samples | |
| t = Ts*(n); % Sampled times | |
| y = cos(2*pi*t); % Discrete signal | |
| Y = fft(y); % The fft of the signal | |
| df = 1/(N*Ts); % The frequency resolution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Define parameters | |
| Fs = 10; % Sampling Frequency | |
| Ts = 1/Fs; % Sampling Period | |
| N = 32; % Total Number of Samples | |
| n = 0:N-1; % Samples | |
| t = Ts*(n); % Sampled times | |
| y = cos(2*pi*t); % Discrete signal | |
| % Plot the signal and its discrete counter-part | |
| figure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Fs = 10; % Sampling frequency | |
| Ts = 1/Fs; % Sampling period | |
| N = 32; % Total number of samples | |
| n = 0:N-1; % Samples | |
| t = Ts*(n); % Sampled times | |
| y = cos(2*pi*t); % Discrete 1 Hz signal | |
| yp = cos(18*pi*t); % Discrete 9 Hz signal | |
| ypp = cos(20*pi*t); % Discrete 10 Hz signal | |
| % Plot the 1 Hz signal and its discrete counter-part |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Plot the useful fft of the signal | |
| figure | |
| stem(f,abs(Y)./N,'filled') | |
| title('Useful Fourier Transform of y') | |
| ylabel('Scaled |fft(y)|') | |
| xlabel('frequency (Hz)') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Y = fft(y); % The fft of the signal | |
| df = 1/(N*Ts); % The frequency resolution | |
| k = n; % Frequency spectrum samples | |
| f = k*df; % Frequency values at the k samples | |
| % Plot the fft of the signal | |
| figure | |
| stem(k,abs(Y),'filled') | |
| title('Raw Fourier Transform of y') | |
| ylabel('|fft(y)|') | |
| xlabel('k') |