how can i generate continuous angle

I am generating quantized angle by using this command 'angle_of_arrival=2*pi*rand(1,3)'. I want to compare my results with continuous angle. How can i generate continuous angle?

답변 (1개)

Star Strider
Star Strider 2016년 7월 23일
편집: Star Strider 2016년 7월 23일

0 개 추천

What do you mean by ‘continuous angle’? (Your ‘angle_of_arrival’ vector is going to have 3 random values between 0 and 2*pi.)
EDIT If by ‘continuous angle’ you mean to have them sorted in increasing order, use the sort function:
angle_of_arrival=2*pi*rand(1,3);
angle_of_arrival = sort(angle_of_arrival);

댓글 수: 3

adnan nizami
adnan nizami 2016년 7월 23일
continuous angle means i want to generate a vector having unquantized angle values. how can i do that?. Actually in my code i want to compare performance error (Quantization error) between continuous angles and quantization angle.
Image Analyst
Image Analyst 2016년 7월 23일
편집: Image Analyst 2016년 7월 23일
You cannot do that. Everything in a digital computer is quantized. Maybe you can find an analog computer somewhere but I'd doubt it.
As a follow up to Star's method. If you want regularly spaced angles in a monotonically increasing or decreasing manner, use the color operator or use the linspace() function.
Everything in computers are by definition ‘quantized’. The rand function generates random numbers (angles here) with full 64-bit floating-point precision, so that is as ‘continuous’ as it is possible to be. (Use format long to see all the digits.)
If you want less precision (more quantization), you can round them to a specific number of digits. Recent versions of MATLAB allow you to do this in the round function itself, and this function will do the same:
roundn = @(x,n) round(x .* 10.^n)./10.^n; % Round ‘x’ To ‘n’ Digits, Emulates Latest ‘round’ Function
Quantization error is uniformly distributed, so use the uniform distribution if you want to describe the statistics.
If you are interested in a short discussion of floating-point approximation error, this is probably the best source: Why is 0.3 - 0.2 - 0.1 (or similar) not equal to zero?

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

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2016년 7월 23일

편집:

2016년 7월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by