필터 지우기
필터 지우기

How to generate random numbers between -pi and pi

조회 수: 7 (최근 30일)
Jelthe
Jelthe 2016년 4월 8일
댓글: Jelthe 2016년 4월 8일
Hi,
i tried generating numbers with linspace(-pi,pi) and i get somewhat the correct numbers. But only for the first run of course. I need random values between -pi and pi for several runs, and all should be other numbers. the rand() function doesnt work with pi

채택된 답변

dpb
dpb 2016년 4월 8일
help rand
...
Example 1: Generate values from the uniform distribution on the interval [a, b].
r = a + (b-a).*rand(100,1);
  댓글 수: 1
Jelthe
Jelthe 2016년 4월 8일
woops. sorry. i should really try before asking. but thank you it worked!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by