필터 지우기
필터 지우기

Creating the uniform distribution on [0,2pi) for 1000 times

조회 수: 19 (최근 30일)
yang-En Hsiao
yang-En Hsiao 2018년 8월 29일
편집: Stephan 2021년 5월 21일
I want to Create the uniform distribution on [0,2pi) for 1000 times,and here is my code
for n = 0:1:1000
theta(n)=0+(2*pi)*rand(1,1)
end
But matlab show me the warning: Subscript indices must either be real positive integers or logicals.I don't understand why does it show me this warning,can anyone tell me where am i wrong?

채택된 답변

Stephan
Stephan 2018년 8월 29일
편집: Stephan 2018년 8월 29일
Hi,
dont start with n=0:
for n = 1:1:1000
theta(n)=0+(2*pi)*rand(1,1);
end
The better way (without loop) is following this and use:
theta = (2*pi)*rand(1,1000);
Best regards
Stephan
  댓글 수: 2
Kinjal Macwan
Kinjal Macwan 2021년 5월 21일
편집: Kinjal Macwan 2021년 5월 21일
@StephanI want to create 500 samples of a signal 𝑑(𝑛) = 𝑠𝑖𝑛 (𝜔0𝑛 +𝜃)
with 𝜔0= 0.05𝜋 and 𝜃 is a random variable that is uniformly distributed between –π and π.
How to write the theta from -pi to pi in this problem?

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by