how can i generate continuous angle
7 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
回答 (1 件)
Star Strider
2016 年 7 月 23 日
編集済み: Star Strider
2016 年 7 月 23 日
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 件のコメント
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.
Star Strider
2016 年 7 月 23 日
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?
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!