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!