Borrar filtros
Borrar filtros

how can i generate continuous angle

7 visualizaciones (últimos 30 días)
adnan nizami
adnan nizami el 23 de Jul. de 2016
Editada: Image Analyst el 23 de Jul. de 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?

Respuestas (1)

Star Strider
Star Strider el 23 de Jul. de 2016
Editada: Star Strider el 23 de Jul. de 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 comentarios
Image Analyst
Image Analyst el 23 de Jul. de 2016
Editada: Image Analyst el 23 de Jul. de 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 el 23 de Jul. de 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?

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by