2015-03-03 35 views
0

下面是QPSK commnication我MATLAB代碼:QPSK星座圖

clc; 
clear all; 
close all; 
data=[0 1 0 1 1 1 0 0 1 1]; % information 
%Number_of_bit=1024; 
%data=randint(Number_of_bit,1); 
figure(1) 
stem(data, 'linewidth',3), grid on; 
title(' Information before Transmiting '); 
axis([ 0 11 0 1.5]); 
data_NZR=2*data-1; % Data Represented at NZR form for QPSK modulation 
s_p_data=reshape(data_NZR,2,length(data)/2); % S/P convertion of data 
br=10.^6; %Let us transmission bit rate 1000000 
f=br; % minimum carrier frequency 
T=1/br; % bit duration 
t=T/99:T/99:T; % Time vector for one bit information 
% XXXXXXXXXXXXXXXXXXXXXXX QPSK modulation XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 
y=[]; 
y_in=[]; 
y_qd=[]; 
for(i=1:length(data)/2) 
    y1=s_p_data(1,i)*cos(2*pi*f*t); % inphase component 
    y2=s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component 
    y_in=[y_in y1]; % inphase signal vector 
    y_qd=[y_qd y2]; %quadrature signal vector 
    y=[y y1+y2]; % modulated signal vector 
end 
Tx_sig=y; % transmitting signal after modulation 
tt=T/99:T/99:(T*length(data))/2; 
figure(2) 
subplot(3,1,1); 
plot(tt,y_in,'linewidth',3), grid on; 
title(' wave form for inphase component in QPSK modulation '); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 
subplot(3,1,2); 
plot(tt,y_qd,'linewidth',3), grid on; 
title(' wave form for Quadrature component in QPSK modulation '); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 
subplot(3,1,3); 
plot(tt,Tx_sig,'r','linewidth',3), grid on; 
title('QPSK modulated signal (sum of inphase and Quadrature phase signal)'); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 

我無法瞭解要使用的值來生成我的代碼相星座圖?我的代碼中的什麼方式可以生成正確的相位星座圖?

============== UPDATE ==============

clc; 
clear all; 
close all; 
data=[0 0 1 1 0 1 1 0 1 1 1 0]; % information 
figure(1) 
stem(data, 'linewidth',3), grid on; 
title(' Information before Transmiting '); 
axis([ 0 11 0 1.5]); 
data_NZR=2*data-1; % Data Represented at NZR form for QPSK modulation 
s_p_data=reshape(data_NZR,2,length(data)/2); % S/P convertion of data 
br=10.^6; %Let us transmission bit rate 1000000 
f=br; % minimum carrier frequency 
T=1/br; % bit duration 
t=T/99:T/99:T; % Time vector for one bit information 
y=[]; 
y_in=[]; 
y_qd=[]; 
d=zeros(1,length(data)/2); 
for i=1:length(data)/2 
    p=data(2*i); 
    imp=data(2*i - 1); 
    y1=s_p_data(1,i)*cos(2*pi*f*t); % inphase component 
    y2=s_p_data(2,i)*sin(2*pi*f*t) ;% Quadrature component 
    y_in=[y_in y1]; % inphase signal vector 
    y_qd=[y_qd y2]; %quadrature signal vector 
    y=[y y1+y2]; % modulated signal vector 
    if (imp == 0) && (p == 0) 
     d(i)=exp(j*pi/4);%45 degrees 
    end 
    if (imp == 1)&&(p == 0) 
     d(i)=exp(j*3*pi/4);%135 degrees 
    end 
    if (imp == 1)&&(p == 1) 
     d(i)=exp(j*5*pi/4);%225 degrees 
    end 
    if (imp == 0)&&(p == 1) 
     d(i)=exp(j*7*pi/4);%315 degrees 
    end 
end 
Tx_sig=y; % transmitting signal after modulation 
qpsk=d; 
tt=T/99:T/99:(T*length(data))/2; 
figure(2) 
subplot(3,1,1); 
plot(tt,y_in,'linewidth',3), grid on; 
title(' wave form for inphase component in QPSK modulation '); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 
subplot(3,1,2); 
plot(tt,y_qd,'linewidth',3), grid on; 
title(' wave form for Quadrature component in QPSK modulation '); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 
subplot(3,1,3); 
plot(tt,Tx_sig,'r','linewidth',3), grid on; 
title('QPSK modulated signal (sum of inphase and Quadrature phase signal)'); 
xlabel('time(sec)'); 
ylabel(' amplitude(volt0'); 
figure(3); 
plot(d,'o');%plot constellation without noise 
axis([-2 2 -2 2]); 
grid on; 
xlabel('real'); ylabel('imag'); 
title('QPSK constellation'); 
+1

不知道你在找什麼。你有沒有嘗試[信號處理StackExchange](http://dsp.stackexchange.com/)? – matthias 2015-03-03 12:56:52

+0

你能舉一個「相位星座圖」的例子嗎?我只知道描繪複雜平面中離散時間數據的星座圖。你喜歡創建星座圖的信號? – Deve 2015-03-03 15:30:51

+0

我想爲我的y_in和y_qd信號值創建星座圖?原諒我的問題框架不正確 – Prakash 2015-03-04 04:36:28

回答

2

的QPSK符號字母表具有四個復碼元。一組隨機QPSK符號可以通過產生隨機整數的數組中1..4和這些數字映射到複數符號創建:

num_symbols = 1e4; 
int_symbols = randi([1, 4], 1, num_symbols); 
A = sqrt(2); 
qpsk_symbols = zeros(size(int_symbols)); 
qpsk_symbols(int_symbols == 1) = A + 1i*A; 
qpsk_symbols(int_symbols == 2) = A - 1i*A; 
qpsk_symbols(int_symbols == 3) = - A + 1i*A; 
qpsk_symbols(int_symbols == 4) = - A - 1i*A; 
tx_sig = qpsk_symbols; 

tx_sig可以是在通信系統中發射的信號。要繪製星座圖,請在繪圖命令中使用實部作爲x值,使用虛部作爲y值。另外,使用作爲'.'線型,使每個值用點只是表示,無線連接:

fh1 = figure; 
plot_lims = [-3 3]; 
plot(real(qpsk_symbols), imag(qpsk_symbols), '.'); 
xlim(plot_lims); 
ylim(plot_lims); 
title('QPSK constellation without noise'); 
xlabel('real part'); 
ylabel('imaginary part'); 

這產生

QPSK contealltion

其示出了四個不同的點。添加噪聲使得這種更有趣:

snr = 15; %// in dB 
rx_sig = awgn(tx_sig, snr, 'measured'); 

fh2 = figure; 
plot(real(rx_sig), imag(rx_sig), '.'); 
xlim(plot_lims); 
ylim(plot_lims); 
title(['QPSK constellation at an SNR of ' num2str(snr) ' dB']); 
xlabel('real part'); 
ylabel('imaginary part'); 

產生

QPSK constellation with noise

這可能是在通信系統中忽略的碼間干擾和其他頻率選擇性成分的接收信號。 (所謂的AWGN信道用於加性高斯白噪聲)。

+1

非常感謝 - 我終於能夠爲我的代碼實現相位星座圖。我相應地修改了代碼。請評論相同。如果沒有你回答和列出的細節,我將永遠無法概念化這個概念。再次感謝 – Prakash 2015-03-05 09:49:03