# A problem with my digital communication code

5 views (last 30 days)
DM on 19 Oct 2014
Commented: Rick Rosson on 19 Oct 2014
I have a problem in writing in MATLAB a program that modulates data bits, adds noise, then demodulates it and calculates the bit error and the symbol error rate. The modulation used first should be QPSK. I have done the following:
N=100;
databits = randi([0 3],N,1);
hModulator = comm.QPSKModulator;
hModulator.PhaseOffset = pi/4;
txsig = step(hModulator, databits);
scatterplot(txsig)
grid on
SNRdB=-10
rxsig = awgn(txsig,SNRdB);
H = comm.QPSKDemodulator
hH.PhaseOffset = pi/4;
symdecoded=step(H,rxsig)
symerr(symdecoded,databits)
biterr(symdecoded, databits)
My first question is I don't think I am doing the bit error rate and symbol error rate correctly, can someone help me spot where the problem is? Where am I missing out?
I am then asked to repeat the same problem but make the changes needed to make it work with 16-QAM and 64-QAM by changing a parameter called CONSTELLATION.
I have tried using demod() and ddemodce() but these two functions have been removed from MATLAB? Does anyone know how to proceed?

Rick Rosson on 19 Oct 2014
Edited: Rick Rosson on 19 Oct 2014
Please try using the General QAM Modulator and Demodulator system objects.
##### 2 CommentsShowHide 1 older comment
Rick Rosson on 19 Oct 2014
[ ~, SER ] = symerr(symdecoded,databits)
[ ~, BER ] = biterr(symdecoded, databits)

Rick Rosson on 19 Oct 2014
hH.PhaseOffset = pi/4;
H.PhaseOffset = pi/4;
DM on 19 Oct 2014
Thanks I did, do you happen to know how to generalize such a program to the QAM case?
{"ft_lang_label":"__label__en","ft_lang_prob":0.79129314,"math_prob":0.79705846,"size":1593,"snap":"2022-40-2023-06","text_gpt3_token_len":439,"char_repetition_ratio":0.10824418,"word_repetition_ratio":0.016129032,"special_character_ratio":0.24105461,"punctuation_ratio":0.13636364,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9505188,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-07T15:06:46Z\",\"WARC-Record-ID\":\"<urn:uuid:cefd0995-880a-423b-a27c-d3f5e46af6b5>\",\"Content-Length\":\"149931\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a489dfb-f52f-4c4b-93bd-c06929392777>\",\"WARC-Concurrent-To\":\"<urn:uuid:40bda2f1-bfc5-47e3-934b-2c1556ee901a>\",\"WARC-IP-Address\":\"104.68.243.15\",\"WARC-Target-URI\":\"https://in.mathworks.com/matlabcentral/answers/159232-a-problem-with-my-digital-communication-code\",\"WARC-Payload-Digest\":\"sha1:4PUF7H2ZYMXXHYZUY7ULGDLOREMZU7KB\",\"WARC-Block-Digest\":\"sha1:QW4MO4AZDBSL75PI3PCH7FJXENRGEAIS\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500619.96_warc_CC-MAIN-20230207134453-20230207164453-00002.warc.gz\"}"}