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

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

This is nothing like an MLS sequence. What you are looking for is often called Bernoulli noise.
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개)

카테고리

도움말 센터File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

제품

태그

질문:

Tom
2012년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by