Effacer les filtres
Effacer les filtres

how can i generate continuous angle

7 vues (au cours des 30 derniers jours)
adnan nizami
adnan nizami le 23 Juil 2016
Modifié(e) : Image Analyst le 23 Juil 2016
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?

Réponses (1)

Star Strider
Star Strider le 23 Juil 2016
Modifié(e) : Star Strider le 23 Juil 2016
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 commentaires
Image Analyst
Image Analyst le 23 Juil 2016
Modifié(e) : Image Analyst le 23 Juil 2016
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.
Star Strider
Star Strider le 23 Juil 2016
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?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by