Generating a Pseudo-random sequence of plus/minus 1 integers

后端 未结 5 542
被撕碎了的回忆
被撕碎了的回忆 2021-01-23 06:24

Can anybody help me create a simple pseudo-random sequence of +-1 integers with length 1000 using Matlab?

I.e. a sequence such as

-1 -1 1 1 -1 -1 1 -1 -         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-23 06:40

    Simply user randsrc function.

    It will generate random sequences of 1 and -1.

    For example

    out = randsrc(2,3)

    out =

    -1    -1    -1
     1    -1     1
    

提交回复
热议问题