%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Creative Commons % Attribution-Noncommercial 2.5 India % You are free: % to Share — to copy, distribute and transmit the work % to Remix — to adapt the work % Under the following conditions: % Attribution. You must attribute the work in the manner % specified by the author or licensor (but not in any way % that suggests that they endorse you or your use of the work). % Noncommercial. You may not use this work for commercial purposes. % For any reuse or distribution, you must make clear to others the % license terms of this work. The best way to do this is with a % link to this web page. % Any of the above conditions can be waived if you get permission % from the copyright holder. % Nothing in this license impairs or restricts the author's moral rights. % http://creativecommons.org/licenses/by-nc/2.5/in/ % Checked for proper operation with Octave Version 3.0.0 % Author : Krishna % Email : krishna@dsplog.com % Version : 1.0 % Date : 14 April 2008 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Script for simulating transmit filtering via a rectangular filtering % sinc fitlering. Both shows that there is no inter-symbol-interference. % However, spectrum of sinc shaped filter is much shorter clear N = 10^4; % number of symbols am = 2*(rand(1,N)>0.5)-1 + j*(2*(rand(1,N)>0.5)-1); % generating random binary sequence fs = 10; % sampling frequency in Hz % recatangular filter gt1 = ones(1,fs); % sinc filter gt2 = sin(pi*[-fs:1/fs:fs])./(pi*[-fs:1/fs:fs]); gt2(fs*fs+1) = 1; % upsampling the transmit sequence amUpSampled = [am;zeros(fs-1,length(am))]; amU = amUpSampled(:).'; % filtered seqeunce st1 = conv(amU,gt1); st2 = conv(amU,gt2); % checking for the difference on the output of the filter to the input sequence errRect = st1(fs:fs:end)-am; errRectSum = errRect*errRect'/N % no difference errSinc = st2(101:10:end-101)-am; errSincSum = errSinc*errSinc'/N % no difference close all [Pxx1,W] = pwelch(st1,[],[],4096,fs); [Pxx2,W] = pwelch(st2,[],[],4096,fs); plot([-2048:2047]*fs/4096,10*log10(fftshift(Pxx1)),'b','LineWidth',2); hold on plot([-2048:2047]*fs/4096,10*log10(fftshift(Pxx2)),'m','LineWidth',2); xlabel('frequency, Hz') ylabel('power spectral density') title('Transmit spectrum'); legend('recatangular', 'sinc'); axis([-2 2 -50 10]) grid on