Changing the center of the frequency spectrum

4 visualizaciones (últimos 30 días)
Jackson
Jackson el 8 de Sept. de 2020
Hi,
I'm trying to plot this wave and have the center of the wave at zero. I was trying to do that by changing the x-axis of the graph but it did not work. The graph is on figure 2 called 'Spectrum of 2PAM signal'.
The Code is:
clear all
close all
fs =48000; %sampling frequency
Ts= 1/fs; %sampling duration
symbolrate = 1000; %transmitted pulses/second should be an integer divisor of fs
symbol_length = fs/symbolrate; %number of samples in one symbol
pulse = ones(1,symbol_length); %1 pulse
textin = input('Enter ASCII text for transmission: ' , 's'); % textin
data_input = dec2bin(double(textin)); %change txtin which is 10# to 2#
[number,length_data] = size(data_input);
data0 = reshape(data_input' , 1,number*length_data); %change the data of matrix to row vector
[number,length_data] = size(data0);
for i = 1:length_data
data(i) = bin2dec(data0(i));
end
[number, length0] = size(data);
symbol = 2*data-1;
for i = 1: length0
for j=1:symbol_length
signal((i-1)*symbol_length + j) = symbol(i) * pulse(j);
end
end
index = 0: Ts: (length0*symbol_length-1)*Ts;
% index = -Ts: Ts:0.01;
freq=fft(signal);
freq=fftshift(freq);
figure(1);
plot(index, signal);
axis([0 1.5*length0*symbol_length*Ts -2 2]);
xlabel('time');
ylabel('amplitude');
title('basband transmission signal of 2PAM');
figure(2);
plot(index, abs(freq));
xlabel('frequency');
ylabel('magnitude');
title('spectrum of 2PAM signal');

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by