필터 지우기
필터 지우기

QAM modulation thru Audio

조회 수: 5 (최근 30일)
muath albrady
muath albrady 2016년 4월 13일
답변: Walter Roberson 2016년 4월 13일
Hi
below is the code that I try to run but its give error said "Input must contain only finite real nonnegative integers."
in bi2de function.
If someone know how to fix it.
thanks a lot.
[y, fs, nbits]=wavread('project.wav'); % find out sampling rate,
N=length(y);
k=log2(nbits);
n = N;
numSamplesPerSymbol = 1;
rng default % Use default random number generator
dataIn = y;
dataInMatrix = reshape(dataIn,length(dataIn)/k,k);
dataSymbolsIn = bi2de(real(dataInMatrix));
dataMod = qammod(dataSymbolsIn,nbits,0); % Binary coding, phase offset = 0
dataModG = qammod(dataSymbolsIn,nbits,0,'gray'); % Gray coding, phase offset = 0
disp('Press any Key to Listen to Modulated Voice'); pause
soundsc(real(dataMod,dataModG))
EbNo = 10;
snr = EbNo + 10*log10(k) - 10*log10(numSamplesPerSymbol);
receivedSignal = awgn(dataMod,snr,'measured');
receivedSignalG = awgn(dataModG,snr,'measured');
disp('Press any Key to Listen to noise Voice'); pause
soundsc(real(receivedSignal,receivedSignalG))
dataSymbolsOut = qamdemod(receivedSignal,nbits); %dem
dataSymbolsOutG = qamdemod(receivedSignalG,nbits,0,'gray');
disp('Press any Key to Listen to Demodulated Voice'); pause
soundsc(real(dataSymbolsOu,dataSymbolsOutG))
dataOutMatrix = de2bi(dataSymbolsOut,k);
dataOut = dataOutMatrix(:); % Return data in column vector
dataOutMatrixG = de2bi(dataSymbolsOutG,k);
dataOutG = dataOutMatrixG(:); % Return data in column vector
[numErrors,ber] = biterr(dataIn,dataOut);
fprintf('\nThe binary coding bit error rate = %5.2e, based on %d errors\n', ...
ber,numErrors)
[numErrorsG,berG] = biterr(dataIn,dataOutG);
fprintf('\nThe Gray coding bit error rate = %5.2e, based on %d errors\n', ...
berG,numErrorsG)

답변 (1개)

Walter Roberson
Walter Roberson 2016년 4월 13일
Your audio data is floating point and has negative values. You arrange it in rows, and use bi2de() on it. bi2de() is for changing binary rows into decimal numbers, and bi2de() expects its input values to be only 0's and 1's.
The solution is not to use de2bi(), as de2bi() only works on non-negative integers.

카테고리

Help CenterFile Exchange에서 QAM에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by