Smallest change for a please
古いコメントを表示
Hi, I have a data for angle in degrees: deg=[10 10 270], and would like to calculate smallest change ie ans=(0 0 80)
2 件のコメント
Walter Roberson
2015 年 10 月 10 日
Smallest change in angle between what and what?
採用された回答
その他の回答 (1 件)
Walter Roberson
2015 年 10 月 11 日
1 投票
80 degrees is not the difference between 10 and 270. 100 degrees is the difference between 10 and 270. You have to pass down through the 10 to 0 degrees and then travel another 90 degrees to reach -90 degrees = 270 degrees, and that is a total of 100 degrees.
4 件のコメント
Aswas
2015 年 10 月 11 日
Walter Roberson
2015 年 10 月 11 日
編集済み: Walter Roberson
2015 年 10 月 11 日
deg = [10 10 270];
t = abs(diff([0 deg]));
result = min(t, 360-t)
Walter Roberson
2015 年 10 月 11 日
I had added the 0 because initially you wanted 3 outputs for 3 inputs.
Aswas
2015 年 10 月 12 日
カテゴリ
ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!