注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mr.Right

不顾一切的去想,于是我们有了梦想。脚踏实地的去做,于是梦想成了现实。

 
 
 

日志

 
 
关于我

人生一年又一年,只要每年都有所积累,有所成长,都有那么一次自己认为满意的花开时刻就好。即使一时不顺,也要敞开胸怀。生命的荣枯并不是简单的重复,一时的得失不是成败的尺度。花开不是荣耀,而是一个美丽的结束,花谢也不是耻辱,而是一个低调的开始。

网易考拉推荐

阿英讲星座图constellation plot的Matlab绘制  

2015-07-03 21:20:59|  分类: 学习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
缘起:通信里信源编码和检测的基本工具。贴出来希望对需要的人有帮助,节省他们的学习摸索时间!南无阿弥陀佛!
 内容包括16PSK和QPSK两种调制类型

% Matlab code for plotting constellation diagram: 
% each constellation symbol can be represented as a complex number. 

clear; close all;
Es = 1; 
M = 16;
k = 0:15;
s = Es*exp(j*2*pi*k/M); % you need to define the value of Es, k, M 
 
% plot the constellation symbol as a red point with size 15. 
plot(s, 'r.', 'markersize', 15); 

 
clear; close all;
Es = 1; 
M = 16;
nBits = 1000;
k = 0:nBits - 1;
s = Es*exp(j*2*pi*k/M); % you need to define the value of Es, k, M 
 


% generate both inphase noise and quadrature noise 
SNR = 25;
noise_var = 10^(-SNR/10);
noise = sqrt(noise_var )*(randn(1, nBits)+j*randn(1, nBits)); 
 
% distorted sample 
r = s + noise; 

% plot the distorted sample as a blue point with size 15 
figure; plot(r, 'b.', 'markersize', 15); hold on;
% plot the constellation symbol as a red point with size 15. 
plot(s, 'r*', 'markersize', 15); 

阿英讲星座图constellation plot的Matlab绘制 - 阿英 - Mr.Right
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The QPSK symbol alphabet has four complex symbols. A set of random QPSK symbols can be created 
% by generating an array of random integer numbers in 1..4 and mapping these numbers to 
% complex symbols:
clear; close all;
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 could be the transmitted signal in a communication system. To plot the constellation 
% diagram, use the real part as x-values and the imaginary part as y-values in the plot command.
% Additionally, use '.' as linestyle, so that every value is just represented by a dot, 
% without line connections:

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');

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');
阿英讲星座图constellation plot的Matlab绘制 - 阿英 - Mr.Right
 
  评论这张
 
阅读(396)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016