Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
prbs_a
Generates a pseudo random binary sequence
Syntax
u = prbs_a(n, nc) u = prbs_a(n, nc, ids) u = prbs_a(n, nc, positions)
Arguments
- n
- positive integer: length of the sequence.
- nc
- integer in [0, n-1]: number of commutations required.
- positions
- vector of integers in [0, n-1]: indices of required commutations in u.
- u
- Row vector of n values in {-1, 1}.
Description
prbs_a()
will be useful to simulate the behavior of a 2-state
random system.
u = prbs_a(n, nc)
builds and returns a row vector
u
made of n
values -1 or +1, in which
nc
commutations from -1 to 1 or from 1 to -1 occur at random
positions in the vector.
The initial state u(1)
has an equiprobable value -1 or +1.
The distribution of commutation positions along u
is statistically
uniform.
The positions of commutations can be retrieved with
find(u(2:$) <> u(1:$-1)) . |
prbs_a(n,,positions)
does the same, but sets commutations at the
given positions
, instead of at random ones. nc
is then ignored. Setting a commutation at a position = i ensures that
u(i+1)
will be -u(i)
.
The initial state can be imposed with a trivial post-processing of the result.
For instance, imposing u(1)=-1
will be done with
if u(1)==1, u = -u; end
.
Examples
clf u = prbs_a(20, 7) subplot(1,2,1) plot2d2(1:20, u, rect=[0,-1.2,20,1.2]); find(u(2:$) <> u(1:$-1)) u = prbs_a(100, 20); subplot(1,2,2) plot2d2(1:100, u, rect=[0,-1.2,100,1.2]);
--> u = prbs_a(20, 7) u = 1. -1. -1. -1. -1. 1. -1. 1. 1. 1. -1. -1. -1. -1. 1. 1. 1. 1. -1. -1. --> find(u(2:$) <> u(1:$-1)) ans = 1. 5. 6. 7. 10. 14. 18.
Example at given positions:
clf u = prbs_a(100, , [13 20 25 40 65 67 80 90 91]); plot2d2(1:100, u, rect=[0,-1.2,100,1.2]); length(u) find(u(2:$)<>u(1:$-1))
--> length(u) ans = 100 --> find(u(2:$)<>u(1:$-1)) ans = 13. 20. 25. 40. 65. 67. 80. 90. 91.
See Also
- noisegen — noise generation (obsolete)
- grand — Random numbers
- sprand — matriz esparsa randômica
- randpencil — feixe aleatório
History
Versão | Descrição |
6.1.0 |
Report an issue | ||
<< noisegen | random | rand >> |