Help using randn and pskmod

I have taken random data using randn and then psk modulated it...But i get error.
M=1024;
m=4;
msg1=randn(M,1,m);
msg2=randn(M,1,m);
msg=vertcat(msg1,msg2);
% QPSK modulation
qpsk_modulated_data1=pskmod(msg1,m);
qpsk_modulated_data2=pskmod(msg2,m);

2 件のコメント

Daniel Shub
Daniel Shub 2012 年 3 月 26 日
What error?
Janet
Janet 2012 年 3 月 26 日
Error using ==> pskmod
Elements of input X must be integers in [0, M-1].

サインインしてコメントする。

 採用された回答

Wayne King
Wayne King 2012 年 3 月 26 日

0 投票

You want to generate your data using randi() like this:
M = 4;
msg1 = randi([0, 3],1024,1);
qpsk_modulated_data1 = pskmod(msg1,M);

8 件のコメント

Janet
Janet 2012 年 3 月 26 日
i get errors
Wayne King
Wayne King 2012 年 3 月 26 日
Janet, I have shown you how to use randi(), which is what you want. Please show what errors you get with the above.
Janet
Janet 2012 年 3 月 26 日
Undefined command/function 'randi'.
Thomas
Thomas 2012 年 3 月 26 日
hmm.. randi is a built-in function..
can you do a
>>which randi
and give the output
Janet
Janet 2012 年 3 月 26 日
am using matlab 7.0...there is no randi function
Wayne King
Wayne King 2012 年 3 月 26 日
How about randint()
msg1 = randint(1024,1,[0,3]);
Daniel Shub
Daniel Shub 2012 年 3 月 26 日
How about round(M*rand(1,m))
Janet
Janet 2012 年 3 月 26 日
@wayne : i get using randint

サインインしてコメントする。

その他の回答 (1 件)

Daniel Shub
Daniel Shub 2012 年 3 月 26 日

0 投票

You realize that
randn(M,1,m)
is not going to produce integers in the range [0, m-1]? Maybe you want
doc randi

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by