FSK Modulation Error (Range of Input Values)

I am trying to write a matlab code for image processing. After computing the DCT for each block in the image and converting decimal matrix to binary and reshaping, I am supposed to do modulation. I tried to use FSK but I keep getting this error:
??? Error using ==> fskmod at 42
Elements of input X must be integers in the range [0, M-1].
------------------------------------------------------------
this is my code:
RGB = imread('cameraman.png');
I = rgb2gray(RGB);
DCT=@dct2
J=blkproc(I,[8 8], DCT);
quanta = 50;
J = double(J) / 255;
J = uint8(J * quanta);
J = double(J) / quanta;
J = reshape(J',[],1);
bstr = dec2bin(J,8) ;
DCT =
@dct2
>> M = 8; k = log2(M);
EbNo = 5;
Fs = 16; nsamp = 17; freqsep = 8;
txsig = fskmod(bstr,M,freqsep,nsamp,Fs); % Modulate.
msg_rx = awgn(txsig,EbNo+10*log10(k)-10*log10(nsamp),...
'measured',[],'dB'); % AWGN channel
msg_rrx = fskdemod(msg_rx,M,freqsep,nsamp,Fs); % Demodulate
[num,BER] = biterr(msg,msg_rrx) % Bit error rate
BER_theory = berawgn(EbNo,'fsk',M,'noncoherent') % Theoretical BER

Answers (2)

dec2bin() produces the characters '0' and '1' as output. fskmod() needs integer values as inputs.
Note: you have only two different input values, but fskmod() expects values to be in the range 0 to M-1 where your M is 8, so you have 8 different allowed input values but are only using two different input values. This should suggest to you that your parameters are wrong or that your transmission is not being optimized.
Nour
Nour on 8 Jan 2013
Edited: Nour on 8 Jan 2013
I tried removing dec2bin(), and I also tried to keep it and have M=2, but I still get the same error.

Asked:

on 8 Jan 2013

Community Treasure Hunt

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

Start Hunting!