Generating truncated sinc function
Hi,
I am Masters student for wireless, i have project in which i have to generate sinc function and have to modulate for 8-PAM with data.
I am 2 problem in this program, 1) generating truncated sinc signal, 2) fft scaling
Generaly for 8-PAM what we do is, we multiply symbol to rectangular pulse to get modulated signal. Now i have to replace that rectrangular pulse by sinc which should have only 10 side lobes(ideally sinc varies from -infi to infi).
Here i am posting my program and its result,
clear all;
close all;
clc;
% 8-Pulse Amplitude Modulation
%initialization
fs = 48000; % Sampling Frequency
ts = 1/fs; % Sampling Period
symbol_rate = 1000; %Symbol Rate
symbol_length = fs/symbol_rate;
pulse = ones(1,symbol_length);% Generating pulse with unit amplitude
string_to_transmit = input('Enter the string you want to modulate : \n','s');
while (isempty(string_to_transmit)==1)
string_to_transmit = input('Kidnly enter the string, thank you: ]n','s');
end
%convert string to ascii value
ascii_value = double(string_to_transmit);
% Generating Binary data represeting ascii values
for k = 0
size(ascii_value,2)-1)
b(k+1,: ) = [zeros(1,7-length(dec2bin(ascii_value(k+1)))) dec2bin(ascii_value(k+1))];
end
binary_values = uint8(b)-48;
[x,y] = size(binary_values);
data = [];
%Generating single Row of data which is to be modulated
for i = 1: x
data(1,end+1:end+y) = binary_values(i,: );
end
%Padding zeros after actual data to complete the 3 bits of transmission
[number,length0] = size(data);
x = rem(length0,3);
if (x ~= 0)
data
,(end+1)
end+(3-x))) = zeros(size(data,1),(3-x));
end
% Symbol generation 1 symbol represent 3 bits
[number,length0] = size(data);
symbol = [];
j = 1;
tau = randi([0,symbol_length]);
for i = 1:3:length0
s(j) = (8*data(i)) + (4*data(i+1)) + (2*data(i+2)) - 7;
j = j+1;
end
%Generating the modulated signal
for i = 1: length0/3
for j=1:symbol_length
signal((i-1)*symbol_length + j+tau) = s(i) * pulse(j);
end
end
%Plotting Modulating Signal and Frequency spectrum
index = 0: ts: ((length0/3)*symbol_length+tau-1)*ts;
freq=fft(signal);
freq=fftshift(freq);
figure(1);
plot(index, signal);
set(gca,'ytick',-9:2:9);
xlabel('time');
ylabel('amplitude');
title('basband transmission signal of 8PAM');
figure(2);
plot(abs(freq));
xlabel('frequency');
ylabel('magnitude');
title('spectrum of 8PAM signal');