I have a domain from 0 : 2*pi and corresponding data points.
I need to shift this data so that the range is -pi : pi (by subtracting 2*pi for all values over pi), while keeping the relationships to the datapoints the same.
I've tried just reordering the data putting 0 in the middle, but this effects other calculations.
My best option so far is manually reordering points, but feel like there is a more efficient way.
Thank you!

 채택된 답변

Walter Roberson
Walter Roberson 2021년 4월 25일

1 개 추천

If you have Mapping Toolbox then there is https://www.mathworks.com/help/map/ref/wraptopi.html
Otherwise,
mask = data > pi;
data(mask) = data(mask) - 2*pi;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2021년 4월 25일

답변:

2021년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by