hello guys!
which way would be the easiest way to repeat a sequence 1000 times ?
this is my code
-------------------------------------------------------
x0=[zeros(1,276) ones(1,290)];
x=x0(randperm(566));
b=(0:566);
d=[x 0]-[0 x];
l=(b(d==(-1))-b(d==1))
L=max(l)
-------------------------------
i want 1000 results of L, i've tried searching for something that might work, but nothing that works.
any ideas?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 16일

0 개 추천

ones(1,1000)*L

댓글 수: 4

Rasmus
Rasmus 2014년 4월 16일
I accepted to early, the answer is good though.
But what if i want L to be different every time? I want the squence to generate a new x all the time. By doing it this way, L is always the same.
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 16일
This is not clear
Rasmus
Rasmus 2014년 4월 16일
편집: Azzi Abdelmalek 2014년 4월 16일
x=x0(randperm(566)); generates a new vector(1,566) of ones and zeroes in a different order.
l=(b(d==(-1))-b(d==1)); gives me the chains of ones of the vector above
L=max(l); gives me the value of longest chain of ones in l
(you of cause know this i am sure)
what i want is to have 1000 different generated results of L, so i can put it into a histogram - This is for probability calculation.
is it possible to make code that gives me this?
Rasmus
Rasmus 2014년 4월 16일
I want to make a loop of this sequence so it repeats it self 1000 times.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2014년 4월 16일

댓글:

2014년 4월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by