课程作业记录1:用matlab仿真BPSK/MPSK信道传输图像

这里是以前做过的一个matlab仿真作业,年代有点久远,把代码传上来记录一下。当时一起的组员为Rebecca Aktins,对我们帮助很大的tutor为Ali,当时才开始写matlab不久,很多地方都有不足之处,注释都是英文的,但是也是因为才开始写,注释写得非常详细,耐心的话应该很好看懂。

当时没有写子函数分块的概念,都写在一起了。

这个代码完成的功能是:设定EbNo的值,输入一个格式为bmp的图片,可以输出一个经过这个信道后的bmp文件,以及其EbNo vs BER的图像。

代码如下:

%function transmitimage(lena1)
clear
lena1 = imread('lena1.bmp')

%Lets make 3 different 128x128 matrices to represent each colour
red= lena1(:,:,1)
green = lena1(:,:,2)
blue = lena1(:,:,3)

%Now to convert them into single column vectors:
red= red(:)
green = green(:)
blue = blue(:)

%Now convert these into binary; note that we are using de2bi, this
%conversion means the right bit is the most significant.
redbin = de2bi(red)
greenbin = de2bi(green)
bluebin = de2bi(blue)

%redbin, greenbin and bluebin are 16384x8 matrices. We now need to convert
%this into single column vectors
redbin = redbin(:)
greenbin = greenbin(:)
bluebin = bluebin(:)

%Now to append these three colmn vectors to one another ready to transmit
lena1bin =[redbin greenbin bluebin]
lena1bin = lena1bin(:)
%Lets change this from uint8 to double precision for when we add noise
lena1bin = double(lena1bin)


%Lets transmit these bits (add noise) and then convert back into a 128x128x3
%matrice

%we firstly need to create our own noise
%Assume A = 1 and T = 1
EbN0 = 6; % in dB
%Convert EbN0 into decibels
EbN0=10^(EbN0/10)
A=1
T=1
Eb = 1/2
N0 = Eb/EbN0;
sd = sqrt(N0*T/4)

%Now to make a column vector of noise the same size as out transmitted
%column vector
X = normrnd(0,s
  • 2
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值