How do I correct meridian labels exceeding 180 degrees with the Mapping Toolbox?
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    MathWorks Support Team
    
 il 20 Mag 2021
  
    
    
    
    
    Risposto: MathWorks Support Team
    
 il 23 Giu 2021
            When labeling meridians in the mapping toolbox, my axis reads [200W 180W 160W] instead of [160E 180W 160W]. How do I correct this?
Risposta accettata
  MathWorks Support Team
    
 il 20 Mag 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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
