trying to make a random number sequence similar to an MLS sequence

4 次查看(过去 30 天)
I'm trying to create a random number sequence like this one: -
x = 2*rand(N,1)-1; % generate input noise signal
except instead of the numbers being at all different values between -1 and 1, I'd like them to be either -1 or 1 only.
Does anyone know how I might do this?
  2 个评论
Daniel Shub
Daniel Shub 2012-4-4
This is nothing like an MLS sequence. What you are looking for is often called Bernoulli noise.
Matt Fig
Matt Fig 2012-11-2
Tom's question
I'm trying to create a random number sequence like this one: -
x = 2*rand(N,1)-1; % generate input noise signal
except instead of the numbers being at all different values between -1 and 1, I'd like them to be either -1 or 1 only.
Does anyone know how I might do this?

请先登录,再进行评论。

采纳的回答

Honglei Chen
Honglei Chen 2012-4-3
a = 2*(randi(2,N,1)-1.5)
or
a = 2*(rand(N,1)>0.5)-1

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by