How do I correct meridian labels exceeding 180 degrees with the Mapping Toolbox?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 20 Mai 2021
Réponse apportée : MathWorks Support Team
le 23 Juin 2021
When labeling meridians in the mapping toolbox, my axis reads [200W 180W 160W] instead of [160E 180W 160W]. How do I correct this?
Réponse acceptée
MathWorks Support Team
le 20 Mai 2021
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!