How do I correct meridian labels exceeding 180 degrees with the Mapping Toolbox?
조회 수: 2 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2021년 5월 20일
답변: MathWorks Support Team
2021년 6월 23일
When labeling meridians in the mapping toolbox, my axis reads [200W 180W 160W] instead of [160E 180W 160W]. How do I correct this?
채택된 답변
MathWorks Support Team
2021년 5월 20일
Use the "wrapTo360" function to change the angle corresponding to each label between 0 to 360 degrees. Additionally, check if the angle turns out to be greater than 180 degrees. If so, do a string replacement to change the label from 'W' to 'E'.
This code will simply need to be pasted at the end of your current code:
h = mlabel('on');
for i=1:length(h)
labelStrings(i)=string(h(i).String{2});
value = str2double(extractBetween(labelStrings(i),2,"^"));
value = wrapTo360(value);
if value > 180
value = 360 - value;
labelStrings(i) = strcat(" ",num2str(value),"^{\circ} E");
h(i).String{2} = labelStrings(i);
end
end
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!