As per my understanding of the question, I could see that you are facing bit errors while demodulating FSK(Frequency Shift Keying) modulated signal using fskdemod.
There are several reasons why bit errors may occur during the demodulation process, following these conditions might help achieve more accurate demodulation and reduces bit errors.
- Signal to Noise Ratio (SNR): Increasing the SNR, either by increasing the signal power or decreasing the noise power, reduces bit errors. This is because a higher SNR means the signal is less affected by noise.
- Nyquist Criterion: Ensuring that the inputs to the fskdemod function satisfy the Nyquist criterion i.e., where is the Sampling Frequency and , denote the frequency deviation and Bit rate per second respectively of the FSK transmitted signal.
Here's my sample implementation following the above conditions which might help you:
samplesPerSymbol = Fs / Rb;
data = randi([0 M-1], numBits, 1);
txSignal = fskmod(data, M, deviation, samplesPerSymbol, Fs);
noisySignal = awgn(txSignal, snrdB, 'measured');
noisySignal = noisySignal / max(abs(noisySignal));
fileID = fopen('IQ_samples.txt', 'w');
fprintf(fileID, '%f %f\n', IQ_samples');
IQ_samples = load('IQ_samples.txt');
rxData = fskdemod(rxSignal, M, deviation, samplesPerSymbol, Fs);
[numErrors, ~] = biterr(data, rxData);
disp(['Number of bit errors: ', num2str(numErrors)]);
In the code provided above, I generated a random data, and Frequency Shift Keying (FSK) modulation is performed using the fskmod function. Noise is then added to the modulated signal with a predefined Signal-to-Noise Ratio (SNR). The IQ samples are saved to a text file, read back, and the I and Q components are extracted. FSK demodulation is carried out using the fskdemod function.
For further help, I suggest you go through the following resources
- https://in.mathworks.com/help/comm/ref/fskdemod.html?s_tid=doc_ta#d126e47038
- Sklar, Bernard. Digital Communications: Fundamentals and Applications. 2nd ed. Upper Saddle River, N.J: Prentice-Hall PTR, 2001.
I hope it helps!