matlab2013b
算法流程如下:
程序主题如下:
登录后复制
clc;clear;close all;warning off;addpath 'func\'addpath 'func_sub\Spread_and_Channel\'addpath 'func_sub\Channel_Est\'addpath 'func_sub\Receiver\'%读取图像源%%%图像源filename1 = 'Images\32\1.jpg';filename2 = 'Images\32\2.jpg';filename3 = 'Images\32\3.jpg';figure;subplot(231);imshow(imread(filename1));title('User1');subplot(232);imshow(imread(filename2));title('User2');subplot(233);imshow(imread(filename3));title('User3');P = 32*32*3*8;%将三个图像源转换为二进制数据[bitsOut1,x,y] = fImageSource(filename1,P);[bitsOut2,x,y] = fImageSource(filename2,P);[bitsOut3,x,y] = fImageSource(filename3,P);databox = 1024; %产生扩频gold码%用户一产生gold码d = 2;shift = [d,d+3,d+6]; [MSeq1] = fMSeqGen([1 0 0 1 1]);[MSeq2] = fMSeqGen([1 1 0 0 1]);%由两个M序列产生GOLD序列GoldSeq1 = fGoldSeq(MSeq1,MSeq2,shift(1))';GoldSeq1(find(GoldSeq1==0)) = -1;GoldSeq2 = fGoldSeq(MSeq1,MSeq2,shift(2))';GoldSeq2(find(GoldSeq2==0)) = -1;GoldSeq3 = fGoldSeq(MSeq1,MSeq2,shift(3))';GoldSeq3(find(GoldSeq3==0)) = -1;Goldseqs = [GoldSeq1 GoldSeq2 GoldSeq3];Gold_Num = length(GoldSeq1); J = [zeros(1,(2*Gold_Num-1)) 0;eye(2*Gold_Num-1) zeros((2*Gold_Num-1),1)];%调制初始参数phi = pi/4;%定义信噪比SNR = 100;%定义三个用户的信道信息,修改信道参数,即可完成task1,2,3的功能实现%arrayArray_Position = [0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0]; %每个用户的多径数,1表示无多径 Path_Num = [1 1 1]';User_Num = length(Path_Num); %DOA:azimuth, elevationDOA_User1= [20 0]; DOA_User2= [70 0];DOA_User3= [120 0];DOA = [DOA_User1; DOA_User2; DOA_User3];%DelayDelay1 = [5]';Delay2 = [8]';Delay3 = [11]';Delay = [Delay1; Delay2; Delay3];%fadingfading1 = [0.9]; fading2 = [0.6]';fading3 = [0.5]';Beta = [fading1; fading2; fading3];%每次发送64个bit,进行循环发送,模拟实际情况for nframes = 1:P/databox fprintf('Now transmit...%d\n\n',nframes); bits1 = [0 0 bitsOut1(databox*(nframes-1)+1:databox*nframes) 0 0]'; bits2 = [0 0 bitsOut2(databox*(nframes-1)+1:databox*nframes) 0 0]'; bits3 = [0 0 bitsOut3(databox*(nframes-1)+1:databox*nframes) 0 0]'; %QPSK,根据星座图进行映射 QPSK1 =fDSQPSKModulator(bits1,Goldseqs(:,1),phi); QPSK2 =fDSQPSKModulator(bits2,Goldseqs(:,2),phi); QPSK3 =fDSQPSKModulator(bits3,Goldseqs(:,3),phi); %扩频处理 All_Photo = [QPSK1 QPSK2 QPSK3]; %扩频,信道处理 R_Channel = fChannel(Path_Num,All_Photo, DOA, Delay, Beta, Goldseqs, Array_Position, SNR); %信道估计 [DOAest,Delayest] = fChannelEstimation(R_Channel,GoldSeq1,Array_Position,Path_Num(1)); %接收机解扩 R = func_Reciver(R_Channel,DOAest,Delayest,Array_Position,GoldSeq1,Path_Num(1)); %De QPSK DeQPSK = fDSQPSKDemodulator(R,GoldSeq1,phi); %DeQPSK = Decoder(R, 'QPSK'); %最后接收到的数据 Final_Rec(databox*(nframes-1)+1:databox*nframes) = DeQPSK; %传输错误个数 sum(abs(bits1(3:end-2)-DeQPSK'))end%图像还原subplot(235);I = fImageSink(Final_Rec,P,x,y);title('The receive data of user1');figure;subplot(121);plot(QPSK1,'o');grid onaxis square;subplot(122);plot(R,'o');axis square;figure;subplot(141);imshow(imread(filename1));subplot(142);plot(QPSK1,'o');grid onaxis square;subplot(143);plot(R,'o');axis square;subplot(144);imshow(uint8(I));axis square;1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.
40db
20 db
0 db
-10db
A01-63
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删