Plot bilinear interpolated gridded data spatially on a map (Cannot get Interp2 to give smooth output)

1 vue (au cours des 30 derniers jours)
I am using the following code to plot gridded data on a map over a region but I would like to know how to plot the interpolated data so that I get continuous data plotted over the region and the data does not look gridded. 'lat' and 'lon' are vectors (1x21 and 1x33) containing the latitude and longitude coordinates respectively.
ax = worldmap(latlim, lonlim);
S = shaperead('landareas','UseGeoCoords',true);
surfacem(lat, lon, ans');
geoshow([S.Lat], [S.Lon],'Color','black');
I am seeing a lot of documentation on using interp2 but I am not getting mine to work even when I try to create a meshgrid using lat and lon (cannot attach the data). I do the following with interp2:
LON,LAT] = meshgrid(unique(lon),unique(lat));
interp2(lon, lat, testdata', LON, LAT);
That gives me a result but I then want to plot it over a region without it looking gridded. testdata is a 33x21 matrix. Any ideas? I have seen some examples here on interpolation but I am not sure how to apply it conveniently with the data I have. I am surprised that there is not more information on this or why I am just sucking at finding the answer!
Thanks,

Réponse acceptée

Chad Greene
Chad Greene le 29 Août 2015
Something to keep in mind: If you only have 33x21 actual data points, a smooth surface plot that does not look gridded will imply to the viewer that you have much higher resolution data than you actually do. But sometimes that's okay. You might not need to use interp2. Instead, simply follow your surfacem command with
shading interp
  1 commentaire
mashtine
mashtine le 1 Sep 2015
Ah! Finally, I can see the light. Many thanks, Chad. It is a bit tricky at time knowing the completely functionality of these packages at times. When I apply this interpretation by the way, my map borders are removed on the first subplot. Any ideas what may be causing this?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by