Contour plot in 2D using x,y,z data
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    SGMukherjee
 le 6 Nov 2021
  
    
    
    
    
    Réponse apportée : Star Strider
      
      
 le 6 Nov 2021
            I have x,y,z datalike this the attached text file. I would like to make a contour plot using this data. I am using the code 
Sublat = Summer2015(:,2);
    Sublong = Summer2015(:,1);
    TECDev = Summer2015(:,3);
  contourf(Sublong,Sublat,TECDev);
But there is an error.
Can you please help?
1 commentaire
Réponse acceptée
  Star Strider
      
      
 le 6 Nov 2021
        Try this — 
Summer2015 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/791769/Summer2015.txt', 'VariableNamingRule','preserve')
Sublat = Summer2015{:,2};
Sublong = Summer2015{:,1};
TECDev = Summer2015{:,3};
latv = linspace(min(Sublat), max(Sublat), height(Summer2015));
lonv = linspace(min(Sublong), max(Sublong), height(Summer2015));
[Lam,Lom] = ndgrid(latv,lonv);
TECDevm = griddata(Sublat, Sublong, TECDev, Lam, Lom);
figure
contourf(Lam, Lom, TECDevm)
axis('equal')
There may be Mapping Toolbox functions for this that could be more appropriate.  Nevertheless, this illustrates how to create the matrices that contourf wants.  
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Contour Plots dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



