⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basesim_mult_blocks.m

📁 这个程序主要是实现空时编码的matlab编解码仿真。
💻 M
📖 第 1 页 / 共 2 页
字号:
    %%%        [corr_maxi,sample_nri,sum_of_r_times_c1i,sum_of_r_times_d2i]=orthosynchronization(mf_inphase_block, fs, T, training_sequence1, training_sequence2, model);	[corr_maxq,sample_nrq,sum_of_r_times_c1q,sum_of_r_times_d2q]=orthosynchronization(mf_quad_block, fs, T, training_sequence1, training_sequence2, model);        %[corr_maxi,sample_nri,sum_of_r_times_c1i,sum_of_r_times_d2i]=synchronization2(mf_inphase_block, fs, T, training_sequence1,training_sequence2, model);    %[corr_maxq,sample_nrq,sum_of_r_times_c1q,sum_of_r_times_d2q]=synchronization2(mf_quad_block, fs, T, training_sequence1, training_sequence2, model);    %corr_maxi    %corr_maxq    %sample_nri    %sample_nrq        %figure(1)    %subplot(2,2,1),plot(sum_of_r_times_c1i),title('train1,inphase')    %subplot(2,2,2),plot(sum_of_r_times_d2i),title('train2,inphase')    %subplot(2,2,3),plot(sum_of_r_times_c1q),title('train1,quad')    %subplot(2,2,4),plot(sum_of_r_times_d2q),title('train2,quad')        if corr_maxq > corr_maxi       % choose the correlation with the biggest max value        sample_nr = sample_nrq;    else        sample_nr = sample_nri;    end        %sample_nr = 81;     block_length=length(outdata_block);    [inphase_symbols]=down_sampler(mf_inphase_block,sample_nr,fs,T,block_length);    [quad_symbols]=down_sampler(mf_quad_block,sample_nr,fs,T,block_length);        %figure(3), subplot(1,2,2), plot(mf_inphase_block), hold on    %for(i=0:block_length-1)    %    plot(i*(fs*T)+sample_nr,inphase_symbols(i+1),'o');    %end    %hold off    %title('Recieved data and samplepoints. (not yet combined!)');    %subplot(1,2,1), stem(outdata_block), axis([-5 35 -0.5 1.5]), title('Sent data.');               
	%%%    %%% Estimating Channel 1 and 2.    %%%
    %[alpha1est,theta1est]=chan_estim7(quad_symbols(1:training_length1),inphase_symbols(1:training_length1),bpsk(training_sequence1,1),1,0.95);    %[alpha1est,theta1est]=channel_estimator_lms_var_d(quad_symbols(1:training_length1),inphase_symbols(1:training_length1)...     %   , bpsk(training_sequence1,1))    [alpha1est,theta1est] = channel_estimator_(quad_symbols(1:training_length1), ...      inphase_symbols(1:training_length1), training_sequence1, model, 1);    if model == 1
       %[alpha2est,theta2est]=chan_estim7(quad_symbols(1:training_length1),inphase_symbols(1:training_length1), bpsk(training_sequence2,1),1,0.95);                       [alpha2est,theta2est]=channel_estimator_(quad_symbols(1:training_length1),...           inphase_symbols(1:training_length1),training_sequence2,model,1);               %[alpha2est,theta2est] = channel_estimator(quad_symbols(1:training_length2), inphase_symbols(1:training_length2), training_sequence2, model, 2);   elseif model == 0        alpha2est = 1;        theta2est = 0;    end % model==1        alpha1;    theta1;    alpha2;    theta2;    % set true values instead:    %alpha1est = alpha1;    %theta1est = theta1;    %alpha2est = alpha2;    %theta2est = theta2;        %alpha1est = 1;    %theta1est = 0;    %alpha2est = 1;    %theta2est = 0;        a1err=alpha1est-alpha1;    a2err=alpha2est-alpha2;    t1err=theta1est-theta1;    t2err=theta2est-theta2;
       a1err_vec=[a1err_vec a1err];    a2err_vec=[a2err_vec a2err];       t1err_vec=[t1err_vec t1err];    t2err_vec=[t2err_vec t2err];             %%%
     %%% The combiner for receiver1
     %%%
        [combined_signal]=combiner(alpha1est, theta1est, alpha2est, theta2est, ...
        inphase_symbols, quad_symbols, model);
     %figure(5), plot(combined_signal((training_length1+training_length2):end),'x'), axis([-6 6 -6 6]), title('Signals after combiner'), grid on
        inphase_symbols = real(combined_signal);        %%%    %%% if rec ==2 receiver2    %%%              if rec == 2       quad2 = imag(receive2(i:i+w_length_pshaped-1));    inphase2 = real(receive2(i:i+w_length_pshaped-1));                                  % figure(6), subplot(2,2,1), plot(1:length(quad2),quad2);       % title('Quad after down-conv, rec2');       % subplot(2,2,2), plot(1:length(inphase2),inphase2);       % title('Inphase after down-conv, rec2');            [mf_quad_block2]=matched_filter(fs, T, pulsetype, quad2);    % Quadrature-part        [mf_inphase_block2]=matched_filter(fs, T, pulsetype, inphase2);    % Inphase-part            %subplot(2,2,3), plot(1:length(mf_quad_block2),mf_quad_block2);        %title('Quad after MF,rec2');        %subplot(2,2,4), plot(1:length(mf_inphase_block2),mf_inphase_block2);        %title('Inphase after MF,rec2');            %%%        %%%     Performing synchronization        %%%        [corr_maxi2,sample_nri2,sum_of_r_times_c1i2,sum_of_r_times_d2i2]=orthosynchronization(mf_inphase_block2, fs, T, training_sequence1, training_sequence2, model);	    [corr_maxq2,sample_nrq2,sum_of_r_times_c1q2,sum_of_r_times_d2q2]=orthosynchronization(mf_quad_block2, fs, T, training_sequence1, training_sequence2, model);                        %[corr_maxi2,sample_nri2,sum_of_r_times_c1i2,sum_of_r_times_d2i2]=synchronization2(mf_inphase_block2, fs, T, training_sequence1,training_sequence2, model);        %[corr_maxq2,sample_nrq2,sum_of_r_times_c1q2,sum_of_r_times_d2q2]=synchronization2(mf_quad_block2, fs, T, training_sequence1, training_sequence2, model);        %[sample_nr2]=synchronization(mf_inphase_block2, fs, T, training_sequence1, model)        %[sample_nr2]=synchronization(mf_inphase_block2, fs, T, training_sequence1, model)        %sample_nr2 = 81;                if corr_maxq2 > corr_maxi2       % choose the correlation with the biggest max value           sample_nr2 = sample_nrq2;        else           sample_nr2 = sample_nri2;        end                 block_length=length(outdata_block);        [inphase_symbols2]=down_sampler(mf_inphase_block2,sample_nr2,fs,T,block_length);        [quad_symbols2]=down_sampler(mf_quad_block2,sample_nr2,fs,T,block_length);            %figure(7), subplot(1,2,2), plot(mf_inphase_block2), hold on        %for(i=0:block_length-1)        %    plot(i*(fs*T)+sample_nr2,inphase_symbols2(i+1),'o');        %end        %hold off        %title('Recieved data and samplepoints. (not yet combined!),rec2');        %subplot(1,2,1), plot(outdata_block), axis([-5 35 -0.5 1.5]), title('Sent data.');                    %figure(8), %subplot(1,2,1),         %plot(inphase_symbols2,quad_symbols2,'x'), axis([-2 2 -2 2]);        %title('Signals after MF and sampled, rec2')    
	    %%%        %%% Estimating Channel 3 and 4.        %%%
           % [alpha3est,theta3est]=channel_estimator_lms(quad_symbols2(1:training_length1),...        %    inphase_symbols2(1:training_length1), bpsk(training_sequence1,1))        [alpha3est,theta3est] = channel_estimator_(quad_symbols2(1:training_length1), ...       inphase_symbols2(1:training_length1), training_sequence1, model, 1);               if model == 1
        %    [alpha4est,theta4est]=channel_estimator_lms(quad_symbols2(training_length1+1:training_length1+ ...         %   training_length2),inphase_symbols2(training_length1+1:training_length1+ ...          %  training_length2), bpsk(training_sequence2,1))               [alpha4est,theta4est] = channel_estimator_(quad_symbols2(1:training_length1), ...
       inphase_symbols2(1:training_length1), training_sequence2, model, 1);       elseif model == 0            alpha4 = 1;            theta4 = 0;        end % model == 1        %alpha3=1;        %theta3=0;        %alpha4=1;        %theta4=0;                %alpha3est = alpha3;        %theta3est = theta3;        %alpha4est = alpha4;        %theta4est = theta4;               a3err=alpha3est-alpha3;        a4err=alpha4est-alpha4;        t3err=theta3est-theta3;        t4err=theta4est-theta4;
                   [combined_signal2]=combiner(alpha3est, theta3est, alpha4est, theta4est, ...
            inphase_symbols2, quad_symbols2, model);
        %figure(9), plot(combined_signal2,'x'), axis([-6 6 -6 6])        %title('Signals after combiner,rec2')             inphase_symbols2 = real(combined_signal2);            %%%        %%% add the signals from receiver1 and receiver2         %%%            inphase_symbols = inphase_symbols + inphase_symbols2;    end %receiver2            %%%
    %%% Detector
    %%%
     
    if model == 1   % if orthogonal training-sequences.        [indata_est,training1_est,training2_est]=detector_ortho(inphase_symbols,training_length1,training_length2,model);    else        [indata_est,training1_est,training2_est]=detector(inphase_symbols,training_length1,training_length2,model);    end    indata_est_vec = [indata_est_vec indata_est];    end % receiver        %disp('Received data is:')
    %indata_est
    %disp('Sent data is:')    %data_block    nr_of_errors = sum(abs(data_block_vec-indata_est_vec));    nr_of_errors_in_rate = nr_of_errors/length(data_block_vec);    error = [error nr_of_errors_in_rate];                   %a1err_mat(gamma0dB(gamma)+1,:) = a1err_vec;    %a2err_mat(gamma0dB(gamma)+1,:) = a2err_vec;    %t1err_mat(gamma0dB(gamma)+1,:) = t1err_vec;    %t2err_mat(gamma0dB(gamma)+1,:) = t2err_vec;        error = mean(error);    EbN0error = [EbN0error error];end % EbN0EbN0error;compared_error = [compared_error EbN0error']end %for(model) compared_error;%figure(11)%semilogy(1:length(compared_error(:,1)),compared_error(:,1),'blue',1:length(compared_error(:,2)),compared_error(:,2),'green')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -