繁体   English   中英

如何在Matlab上结合两个功能?

[英]How do i combine two functions on matlab?

我需要帮助,(据我所知它应该很简单,但是我不经常使用Matlab。)

我有一个图用于降雨引起的波衰减。 而且,我有一张显示误码率(BER)(仅受白噪声影响)的图表。

除了白噪声外,我还希望通过扣除图来提高误码率影响图。

在BER代码中,白鼻子显示为“ awgn”。那么,如何将衰减图与“通过AWGN通道”的第一个代码结合起来? 提前致谢!

衰减图 BER图

BER代码:

M = 64;                 % Modulation order
k = log2(M);            % Bits per symbol
EbNoVec = (5:15)';      % Eb/No values (dB)
numSymPerFrame = 100;

for n = 1:length(EbNoVec)
    % Convert Eb/No to SNR
    snrdB = EbNoVec(n) + 10*log10(k);
    % Reset the error and bit counters
    numErrs = 0;
    numBits = 0;

    while numErrs < 200 && numBits < 1e7
        % Generate binary data and convert to symbols
        dataIn = randi([0 1],numSymPerFrame,k);
        dataSym = bi2de(dataIn);

        % QAM modulate using 'Gray' symbol mapping
        txSig = qammod(dataSym,M);

        % Pass through AWGN channel
        rxSig = awgn(txSig,snrdB,'measured');

        % Demodulate the noisy signal
        rxSym = qamdemod(rxSig,M);
        % Convert received symbols to bits
        dataOut = de2bi(rxSym,k);

        % Calculate the number of bit errors
        nErrors = biterr(dataIn,dataOut);

        % Increment the error and bit counters
        numErrs = numErrs + nErrors;
        numBits = numBits + numSymPerFrame*k;
    end

    % Estimate the BER
    berEst(n) = numErrs/numBits;
end

berTheory = berawgn(EbNoVec,'qam',M);

semilogy(EbNoVec,berEst,'*')
hold on
semilogy(EbNoVec,berTheory)
grid
legend('Estimated BER','Theoretical BER')
xlabel('Eb/No (dB)')
ylabel('Bit Error Rate')

波衰减代码:

R = 1000.0;
freq = [10:1000]*1e9;
T = 20.0;
lwd = 0.5;
F = fogpl(R,freq,T,lwd);
P = 101300.0;
W = 7.5;
G = gaspl(R,freq,T,P,W);
RR=[0.75,1.75,2.5,3];
for irr=1:length(RR)
R = rainpl(10000,freq,RR(irr));
L=R+F+G;
loglog(freq/1e9,L);
hold on;
grid
title('rain attenuation')
xlabel('Frequency (GHz)')
ylabel('Attenuation (dB)')
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM